Skip to content

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

@ppenzin

Description

@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

(this is a build bug, there's no JS code to execute)

Exception or Error

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 llvm/llvm-project#163517. We are not bound to hit this in regular distro build soon, because packages (especially Ubuntu) have rather old version of Clang.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions