[Bug c++/41131] New: non-lvalue in unary `&' wrongly accepted

sergei_lus at yahoo dot com gcc-bugzilla@gcc.gnu.org
Thu Aug 20 15:12:00 GMT 2009


According to the iso 14882:1998 5.2.5 Class member access, the following code:

class X {
public:
        enum enumX { a=100 };
};
int main(void)
{
        X x;
        (void) &x.a;    // should not compile
        return  1;
}

should not compile, but with the following version of g++:
g++ -v
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../configure --enable-threads=posix
--prefix=/prj/dsp/qdsp6_aus/users/slarin/x86_gcc_4.4/bin
--enable-languages=c,c++ --disable-checking
Thread model: posix
gcc version 4.4.0 (GCC)

... it does. Also failing in 4.3.2. In 3.3.3 and 3.4.6 for example it correctly
reports the following:

g++ reduced.c
reduced.c: In function `int main()':
reduced.c:11: error: non-lvalue in unary `&'


Thank you.


-- 
           Summary: non-lvalue in unary `&' wrongly accepted
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sergei_lus at yahoo dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41131



More information about the Gcc-bugs mailing list