This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/49311] Missing static const symbol with -O0
- From: "hartmut.schirmer at arcormail dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 8 Jun 2011 05:26:06 +0000
- Subject: [Bug c++/49311] Missing static const symbol with -O0
- Auto-submitted: auto-generated
- References: <bug-49311-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49311
--- Comment #5 from Hartmut Schirmer <hartmut.schirmer at arcormail dot de> 2011-06-08 05:25:44 UTC ---
> I think there are several hundred already.
Oh, this list was helpful, thanks!
> Not worth marking them as duplicate,
> it just further upsets people receiving notifications for a problem that has no
> solution.
Looking at http://www2.research.att.com/~bs/bs_faq2.html#in-class I found this
"You can take the address of a static member if (and only if) it has an
out-of-class definition"
Of course this is not a promise you don't need an out-of-class definition if
you don't take the address. Gcc uses the assumption it can take the address in
-O0 mode, but is this assumption justified? It's at least surprising.
class A
{
public:
static const unsigned first = 1;
enum { second = 2 };
};
should behave similar in all cases address of first isn't taken.