[Bug c++/107939] [11/12/13 Regression] Rejects use of `extern const` variable in a template

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Nov 30 19:35:56 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107939

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |needs-bisection
   Target Milestone|---                         |11.4
            Summary|Rejects use of `extern      |[11/12/13 Regression]
                   |const` variable in a        |Rejects use of `extern
                   |template                    |const` variable in a
                   |                            |template
   Last reconfirmed|                            |2022-11-30
     Ever confirmed|0                           |1

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Replacing auto with int (and adding a message to static_assert), gets you a
valid C++14 testcase:
```

struct Q {
  struct P {
    const Q* p;
  };
  int n;
  constexpr P operator()(int) const { return {this}; }
};

extern const Q q;

#if 1
template<int> constexpr auto p = q(0);
static_assert(p<0>.p == &q, "");
#else
constexpr auto p = q(0);
static_assert(p.p == &q, "");
#endif

constexpr Q q = {};
```
This worked with GCC 10.4.0.


More information about the Gcc-bugs mailing list