Bug 92073 - references/pointers to thread_local are not constant expressions
Summary: references/pointers to thread_local are not constant expressions
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 10.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid
Depends on:
Blocks: constexpr
  Show dependency treegraph
 
Reported: 2019-10-11 23:43 UTC by tyker
Modified: 2021-11-24 09:02 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-08-22 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tyker 2019-10-11 23:43:05 UTC
currently gcc accepts the folowing:
```
template<int &data>
struct A {};

static thread_local int b;

A<b> a;
```
this is not valid. 
http://eel.is/c++draft/expr.const#10.2
says if a constant expression is a pointer to an object it should be in static storage.

also, compilers(icc, clang, msvc) reject this code https://godbolt.org/z/d47fb9
Comment 1 Drea Pinski 2021-08-22 23:10:18 UTC
Confirmed.