public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/44692]  New: Ambiguous member names in anonymous struct/union does not error
@ 2010-06-27 18:20 mark-gcc at pogo dot org dot uk
  2010-06-27 18:22 ` [Bug c/44692] " mark-gcc at pogo dot org dot uk
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: mark-gcc at pogo dot org dot uk @ 2010-06-27 18:20 UTC (permalink / raw)
  To: gcc-bugs

The manual:

  http://gcc.gnu.org/onlinedocs/gcc/Unnamed-Fields.html

states that the compiler gives an error for constructs which are ambigious.
However I could not produce this error, even using the example on that page:

     struct {
       int a;
       struct {
         int a;
       };
     } foo;

I was first made aware of this with a structure like the following. This also
does not produce any compiler error, either at definition or where member
variables are used:

union {
  int a;
  struct {
    int x;
    int a;
  };
} bar;

Instead, where 'a' is used, the first definition is seen to be used, silently
with no error or warning. This is more serious, because use of x overwrites a.

Test platform is GCC 4.5.0 (Arch Linux), building with -Wall. Also verified on
GCC 4.3.3 (Slackware Linux)

vega$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-pc-linux-gnu/4.5.0/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: ../configure --prefix=/usr
--enable-languages=c,c++,fortran,objc,obj-c++,ada --enable-shared
--enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu
--enable-gnu-unique-object --enable-lto --enable-plugin --disable-multilib
--disable-libstdcxx-pch --with-system-zlib --with-ppl --with-cloog
--libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man
--infodir=/usr/share/info
Thread model: posix
gcc version 4.5.0 20100610 (prerelease) (GCC)


-- 
           Summary: Ambiguous member names in anonymous struct/union does
                    not error
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mark-gcc at pogo dot org dot uk
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/44692] Ambiguous member names in anonymous struct/union does not error
  2010-06-27 18:20 [Bug c/44692] New: Ambiguous member names in anonymous struct/union does not error mark-gcc at pogo dot org dot uk
  2010-06-27 18:22 ` [Bug c/44692] " mark-gcc at pogo dot org dot uk
@ 2010-06-27 18:22 ` mark-gcc at pogo dot org dot uk
  2010-06-27 18:32 ` jsm28 at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: mark-gcc at pogo dot org dot uk @ 2010-06-27 18:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from mark-gcc at pogo dot org dot uk  2010-06-27 18:22 -------
Created an attachment (id=21019)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21019&action=view)
Preprocessed source code


-- 


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/44692] Ambiguous member names in anonymous struct/union does not error
  2010-06-27 18:20 [Bug c/44692] New: Ambiguous member names in anonymous struct/union does not error mark-gcc at pogo dot org dot uk
@ 2010-06-27 18:22 ` mark-gcc at pogo dot org dot uk
  2010-06-27 18:22 ` mark-gcc at pogo dot org dot uk
  2010-06-27 18:32 ` jsm28 at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: mark-gcc at pogo dot org dot uk @ 2010-06-27 18:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from mark-gcc at pogo dot org dot uk  2010-06-27 18:22 -------
Created an attachment (id=21018)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21018&action=view)
Example program

Source code, compile and test with:

  gcc -Wall anon.c && ./a.out


-- 


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/44692] Ambiguous member names in anonymous struct/union does not error
  2010-06-27 18:20 [Bug c/44692] New: Ambiguous member names in anonymous struct/union does not error mark-gcc at pogo dot org dot uk
  2010-06-27 18:22 ` [Bug c/44692] " mark-gcc at pogo dot org dot uk
  2010-06-27 18:22 ` mark-gcc at pogo dot org dot uk
@ 2010-06-27 18:32 ` jsm28 at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2010-06-27 18:32 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from jsm28 at gcc dot gnu dot org  2010-06-27 18:31 -------
That documentation is for current development sources, where those errors
are given.  Note that

http://gcc.gnu.org/onlinedocs/gcc-4.5.0/gcc/Unnamed-Fields.html

has different wording.


-- 

jsm28 at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-06-27 18:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-27 18:20 [Bug c/44692] New: Ambiguous member names in anonymous struct/union does not error mark-gcc at pogo dot org dot uk
2010-06-27 18:22 ` [Bug c/44692] " mark-gcc at pogo dot org dot uk
2010-06-27 18:22 ` mark-gcc at pogo dot org dot uk
2010-06-27 18:32 ` jsm28 at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).