[Bug c++/83271] const variable previously declared "extern" results in "weak declaration must be public" error

alexey.salmin at gmail dot com gcc-bugzilla@gcc.gnu.org
Mon Dec 4 20:43:00 GMT 2017


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

--- Comment #4 from Alexey Salmin <alexey.salmin at gmail dot com> ---
(In reply to Jonathan Wakely from comment #3)
> At least there's a simple workaround (adding 'extern' to the definition
> where the attribute).

That's what we do, so this is really a minor bug. Still, I decided to report it
for a few reasons:
1) Current g++ behavior looks inconsistent
2) clang++ and icc handle this case correctly
3) I'm used to a practice where declarations has the "extern" specifier while
definitions don't. This matters when you rely on the zero-initialization which
I normally don't do, but this pattern is somehow stuck in my head


More information about the Gcc-bugs mailing list