[Bug c++/10930] New: g++-3.3 should warn about class/struct equivalence

thor@math.tu-berlin.de gcc-bugzilla@gcc.gnu.org
Thu May 22 11:35:00 GMT 2003

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.


           Summary: g++-3.3 should warn about class/struct equivalence
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P2
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: thor@math.tu-berlin.de
                CC: gcc-bugs@gcc.gnu.org
 GCC build triplet: i386-pc-linux-gnu
  GCC host triplet: i386-pc-linux-gnu
GCC target triplet: i386-pc-linux-gnu

g++-3.3 should warn about an object declared as a class that is later on 
used as a "struct". This would simplify the generation of portable code 
as at least one other popular compiler will generate warnings for this 
case that could be easily avoided by this additional g++ warning. This would
make life simpler for those that have to support several platforms. This issue
is not whether the requested warning is "useful" as a C++ warning.
Besides, implementation seems to be simple for me.

Save the following code as "foo.cpp"
/* snip */
class A {
   int x;

int main(int,char)
   struct A a;

   return 0;
/* snip */
And compile with

$ g++-3.3 -Wall -pedantic foo.cpp

The resulting code works. (-; It would be nice if g++ could generate a 
warning (e.g. by passing a -Wstruct-class-equivalence) that "class A" has been
used as "struct A a;" in main(), instead of  "class A a;" or rather "A a;".

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.

More information about the Gcc-bugs mailing list