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

Reply via email to