Issue 97830
Summary C23 constexpr should not have external linkage
Labels new issue
Assignees
Reporter gustedt
    Hi,
thanks for implementing `constexpr` for clang-19!

The following code

```{.C}
constexpr int category_width = 5;
int const w = 5;
int const* a = &category_width;
```
compiles, but produces an external symbol for `category_width` and then multiple defined symbol errors on linkage. So I cannot use `constexpr` in header files, or I'd have to prefix it with `static`, which defeats the purpose of `constexpr` ...

C23 has in 6.2.2 p3

> If the declaration of a file scope identifier for:
> — an object contains any of the storage-class specifiers `static` or `constexpr`;
> — or, a function contains the storage-class specifier `static`,
> then the identifier has internal linkage.

Thanks
Jens
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to