Issue 163517
Summary [clang] New error in clang21, in-class initializer for static data member is not a constant _expression_
Labels clang
Assignees
Reporter lingege321
    Hi experts,

I'm updating the clang version from 20 to 21 and see the new error in my project.
The error is introduced from a third-party library and I reduce the code size to a minimum issue.
Please check the compiler-explorer, https://godbolt.org/z/x73rfhWfW


Seems that static member variable must be a constant _expression_.
However, in this case, `type(BOUND+1)` is not a constant _expression_ in clang21 but I think it should be considered as a constant _expression_.

I have some workaround for it but I don't want to do that because it's a third party library.

Is it possible to support this code?

```
struct Test {
    enum type {
 Type1,
        BOUND
    };
    static const type binding_required = BOUND;
    static const type binding_completed = type(BOUND+1);
    static const type detached = type(binding_completed+1);
    static const type dying = type(detached+1);
};
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to