First I cannot find the exact C++ definition of "const anonymous object" so I
am not sure the below reporting is valid or not. The question to me is: why
adding 'const' to the class declaration will invalidate the code while without
'const' is ok?

The following code will compile and run without error, but if add back the
"const" declaration before 'class', it will report an error of "
 Error: uninitialized const `MyAnonymous'"
This had been tested with gcc 3.3.3 & 4.1.2.

/* const */ class
{
 public:
   int foo() const
   {
      return 1;
   }
} MyAnonymous;

int
main()
{
  return MyAnonymous.foo();
}


-- 
           Summary: cause compile error for "const anonymous class object"
           Product: gcc
           Version: 3.3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gzljg at hotmail dot com


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

Reply via email to