Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

size of array ‘altStackMem’ is not an integral constant-expression #11

Open
blueglyph opened this issue Oct 26, 2022 · 0 comments
Open

Comments

@blueglyph
Copy link

Problem

I get the following error when compiling the tests:

In file included from /usr/include/signal.h:328,
                 from /home/projects/c/Drachennest/test/catch.hpp:6456,
                 from /home/projects/c/Drachennest/test/catch_main.cc:2:
/home/projects/c/Drachennest/test/catch.hpp:6631:45: error: size of array ‘altStackMem’ is not an integral constant-expression
 6631 |     char FatalConditionHandler::altStackMem[SIGSTKSZ] = {};
      |                                             ^~~~~~~~

I saw this notice for glibc 2.34, which seems relevant to the issue:

12 * Add _SC_MINSIGSTKSZ and _SC_SIGSTKSZ. When _SC_SIGSTKSZ_SOURCE or
13 _GNU_SOURCE are defined, MINSIGSTKSZ and SIGSTKSZ are no longer
14 constant on Linux. MINSIGSTKSZ is redefined to sysconf(_SC_MINSIGSTKSZ)
15 and SIGSTKSZ is redefined to sysconf (_SC_SIGSTKSZ).

So this problem is bound to creep in projects using those #defines.

Steps to reproduce

git clone https://github.com/abolz/Drachennest.git
cd Drachennest/
mkdir build
cd build/
cmake ..
cd test
cmake --build .

Work-around

diff --git a/test/catch.hpp b/test/catch.hpp
index 1106e46..cdbe953 100644
--- a/test/catch.hpp
+++ b/test/catch.hpp
@@ -6628,6 +6628,11 @@ namespace Catch {
     bool FatalConditionHandler::isSet = false;
     struct sigaction FatalConditionHandler::oldSigActions[sizeof(signalDefs)/sizeof(SignalDefs)] = {};
     stack_t FatalConditionHandler::oldSigStack = {};
+
+// FIXME: temporary fix
+# undef SIGSTKSZ
+# define SIGSTKSZ _SC_SIGSTKSZ
+
     char FatalConditionHandler::altStackMem[SIGSTKSZ] = {};
 
 } // namespace Catch

Environment

ldd (GNU libc) 2.36
gcc (GCC) 12.2.0
Linux manj 5.15.74-3-MANJARO x86_64 GNU/Linux

Other info

Trying to compile everything in build shows many other errors that I didn't investigate.

The first was:

[ 85%] Building CXX object bench/CMakeFiles/bench_dtoa.dir/bench_dtoa.cc.o
/home/projects/c/Drachennest/bench/bench_dtoa.cc:177:22: error: ‘JenkinsRandom random’ redeclared as different kind of entity
  177 | static JenkinsRandom random;
      |                      ^~~~~~
In file included from /usr/include/c++/12.2.0/cstdlib:75,
                 from /usr/include/c++/12.2.0/bits/stl_algo.h:69,
                 from /usr/include/c++/12.2.0/algorithm:61,
                 from /home/projects/c/Drachennest/ext/google_benchmark/include/benchmark/benchmark.h:172,
                 from /home/projects/c/Drachennest/bench/bench_dtoa.cc:1:
/usr/include/stdlib.h:402:17: note: previous declaration ‘long int random()’
  402 | extern long int random (void) __THROW;
      |                 ^~~~~~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant