Skip to content

Conversation

@gregtatum
Copy link

Description

I'm building on macOS arm64 using clang and encountered a bug with a compile error.

Example error:

[ 50%] Building CXX object src/CMakeFiles/marian.dir/3rd_party/ExceptionWithCallStack.cpp.o /Users/greg/dev/marian-dev/src/3rd_party/ExceptionWithCallStack.cpp:205:30: error: variable length arrays in C++ are a Clang extension [-Werror,-Wvla-cxx-extension]
  205 |     void* backtraceAddresses[MAX_NUM_FRAMES];
      |                              ^~~~~~~~~~~~~~
/Users/greg/dev/marian-dev/src/3rd_party/ExceptionWithCallStack.cpp:205:30: note: read of non-const variable 'MAX_NUM_FRAMES' is not allowed in a constant expression
/Users/greg/dev/marian-dev/src/3rd_party/ExceptionWithCallStack.cpp:204:18: note: declared here
  204 |     unsigned int MAX_NUM_FRAMES = 1024;
      |                  ^
/Users/greg/dev/marian-dev/src/3rd_party/ExceptionWithCallStack.cpp:239:27: error: variable length arrays in C++ are a Clang extension [-Werror,-Wvla-cxx-extension]
  239 |             char funcName[MAX_FUNCNAME_SIZE]; // working buffer
      |                           ^~~~~~~~~~~~~~~~~
/Users/greg/dev/marian-dev/src/3rd_party/ExceptionWithCallStack.cpp:239:27: note: read of non-const variable 'MAX_FUNCNAME_SIZE' is not allowed in a constant expression
/Users/greg/dev/marian-dev/src/3rd_party/ExceptionWithCallStack.cpp:237:26: note: declared here
  237 |             unsigned int MAX_FUNCNAME_SIZE = 4096;
      |                          ^
2 errors generated.

This change makes it so that the values are constexpr and fixes the build error.

List of changes:

  • Added constexpr to two lines

How to test

This shouldn't change any behavior, and just needs a build to verify. I have run make test but the full regression tests don't work on my machine.

Checklist

  • I have tested the code manually
  • I have run regression tests
  • I have read and followed CONTRIBUTING.md
  • I have updated CHANGELOG.md

Example error:

[ 50%] Building CXX object src/CMakeFiles/marian.dir/3rd_party/ExceptionWithCallStack.cpp.o
/Users/greg/dev/marian-dev/src/3rd_party/ExceptionWithCallStack.cpp:205:30: error: variable length arrays in C++ are a Clang extension [-Werror,-Wvla-cxx-extension]
  205 |     void* backtraceAddresses[MAX_NUM_FRAMES];
      |                              ^~~~~~~~~~~~~~
/Users/greg/dev/marian-dev/src/3rd_party/ExceptionWithCallStack.cpp:205:30: note: read of non-const variable 'MAX_NUM_FRAMES' is not allowed in a constant expression
/Users/greg/dev/marian-dev/src/3rd_party/ExceptionWithCallStack.cpp:204:18: note: declared here
  204 |     unsigned int MAX_NUM_FRAMES = 1024;
      |                  ^
/Users/greg/dev/marian-dev/src/3rd_party/ExceptionWithCallStack.cpp:239:27: error: variable length arrays in C++ are a Clang extension [-Werror,-Wvla-cxx-extension]
  239 |             char funcName[MAX_FUNCNAME_SIZE]; // working buffer
      |                           ^~~~~~~~~~~~~~~~~
/Users/greg/dev/marian-dev/src/3rd_party/ExceptionWithCallStack.cpp:239:27: note: read of non-const variable 'MAX_FUNCNAME_SIZE' is not allowed in a constant expression
/Users/greg/dev/marian-dev/src/3rd_party/ExceptionWithCallStack.cpp:237:26: note: declared here
  237 |             unsigned int MAX_FUNCNAME_SIZE = 4096;
      |                          ^
2 errors generated.
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

Successfully merging this pull request may close these issues.

1 participant