Clang 21: in-class initializer for static data member is not a constant expression

#7050 ยท closed ยท 3 comments

View on GitHub โ†—

ppenzin

### ChakraCore Version master ### Steps to reproduce Get clang 21 or newer (I used current LLVM 'main') on Linux and build via CMake. ### Proof of concept ```js (this is a build bug, there's no JS code to execute) ``` ### Exception or Error ```text lib/Runtime/Library/IntlEngineInterfaceExtensionObject.cpp:2260:42: error: in-class initializer for static data member is not a constant expression 2260 | static const UNumberFormatFields UnsetField = static_cast<UNumberFormatFields>(0xFFFFFFFF); | ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lib/Runtime/Library/IntlEngineInterfaceExtensionObject.cpp:2260:55: note: integer value 4294967295 is outside the valid range of values [0, 15] for the enumeration type 'UNumberFormatFields' 2260 | static const UNumberFormatFields UnsetField = static_cast<UNumberFormatFields>(0xFFFFFFFF); | ^ 1 error generated. [10/184] Building CXX object lib/Runti...y.dir/JavascriptBuiltInFunctions.cpp.o ninja: build stopped: subcommand failed. ``` ### Additional Context This is new check introduced in version 21 described in https://github.com/llvm/llvm-project/issues/163517. We are not bound to hit this in regular distro build soon, because packages (especially Ubuntu) have rather old version of Clang.

Comments

ppenzin

As an aside, we might want to add a 'build bug' template that wouldn't require POC code.

ShortDevelopment

> As an aside, we might want to add a 'build bug' template that wouldn't require POC code. That's the second one ๐Ÿ˜‰ [.github/ISSUE_TEMPLATE/02-build-issue.yml](https://github.com/chakra-core/ChakraCore/blob/master/.github/ISSUE_TEMPLATE/02-build-issue.yml)

ppenzin

Yeah, found that as well ๐Ÿ˜„