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 09:58:21 +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 #7 from Hartmut Schirmer <hartmut.schirmer at arcormail dot de> 2011-06-08 09:57:58 UTC ---
> > class A
> > {
> > public:
> > static const unsigned first = 1;
> > enum { second = 2 };
> > };
> >
> > should behave similar in all cases address of first isn't taken.
>
> But your code requires an lvalue because the result of the conditional operator
> is an lvalue if both arguments are lvalues, so it must have an address.
>
> That's why casting the operands or adding zero makes it link, because it makes
> the operand an rvalue, so the address is not needed.
>
> This is explained in the duplicate PRs I linked to, please read them, there's
> nothing more to discuss IMHO.
Does the way I use an rvalue change it's definition?
So if A and B are rvalue's does
c = x ? A : B
to mutate to lvalues?
Looking at http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#454
the compiler should handle static const data members like rvalues wherever
possible. Currently gcc does so nearly all the time, the few exceptions cause
really unexpected troubles