public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/19435] New: spurious warnings with nested array constructors
@ 2005-01-14  3:08 rfeany at mrv dot com
  2005-01-14  3:14 ` [Bug c/19435] " pinskia at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: rfeany at mrv dot com @ 2005-01-14  3:08 UTC (permalink / raw)
  To: gcc-bugs

I have tried this with both gcc 3.3.5 and 3.4.4:

gcc-3.4 (GCC) 3.4.4 20041218 (prerelease) (Debian 3.4.3-6)
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

gcc (GCC) 3.3.5 (Debian 1:3.3.5-5)
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Here is code:

struct thing {
    unsigned char *ptr;
};

struct thing array[1] = {
    { .ptr = ((unsigned char []) { 0x1, 0x2 }) }
};

And the warnings I don't think I should be getting:

{rfeany@bugs}$ gcc-3.4 -c test.c 
test.c:9: warning: excess elements in array initializer
test.c:9: warning: (near initialization for `(anonymous)')


If i change array[1] to array[2] then I recieve no warnings.
It seems as if the outside array size is being used to check the internal
array constructor thinggy.

-- 
           Summary: spurious warnings with nested array constructors
           Product: gcc
           Version: 3.4.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rfeany at mrv dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

* [Bug c/19435] spurious warnings with nested array constructors
  2005-01-14  3:08 [Bug c/19435] New: spurious warnings with nested array constructors rfeany at mrv dot com
@ 2005-01-14  3:14 ` pinskia at gcc dot gnu dot org
  2005-01-21 13:37 ` mmikucionis at gmail dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-14  3:14 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-01-14 03:13 -------
Confirmed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |rejects-valid, wrong-code
   Last reconfirmed|0000-00-00 00:00:00         |2005-01-14 03:13:57
               date|                            |


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


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

* [Bug c/19435] spurious warnings with nested array constructors
  2005-01-14  3:08 [Bug c/19435] New: spurious warnings with nested array constructors rfeany at mrv dot com
  2005-01-14  3:14 ` [Bug c/19435] " pinskia at gcc dot gnu dot org
@ 2005-01-21 13:37 ` mmikucionis at gmail dot com
  2005-01-21 14:31 ` mmikucionis at gmail dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: mmikucionis at gmail dot com @ 2005-01-21 13:37 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mmikucionis at gmail dot com  2005-01-21 13:37 -------
I have very similar situation but with even worse results:

struct foo {
  int i;
  char* s[];
} arr[] = {
  {
    1, { "first", "second" }
  },
  {
    2, { "third", "fourth" }
  }
};

gcc (GCC) 3.3.5 (Debian 1:3.3.5-6) and gcc-3.4 (GCC) 3.4.4 20041218 (prerelease)
(Debian 3.4.3-7) say the following:
$ gcc-3.3 struct.cc
struct.cc:11: internal compiler error: in tree_low_cst, at tree.c:3255
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
For Debian GNU/Linux specific bug reporting instructions, see
<URL:file:///usr/share/doc/gcc-3.3/README.Bugs>.

gcc 2.95.4 says the following:
$ gcc-2.95 struct.cc
struct.cc:11: excess elements in aggregate initializer
struct.cc:11: excess elements in aggregate initializer

I am not sure whether the code is correct according to standards, 
but gcc should not break there :-/

-- 


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


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

* [Bug c/19435] spurious warnings with nested array constructors
  2005-01-14  3:08 [Bug c/19435] New: spurious warnings with nested array constructors rfeany at mrv dot com
  2005-01-14  3:14 ` [Bug c/19435] " pinskia at gcc dot gnu dot org
  2005-01-21 13:37 ` mmikucionis at gmail dot com
@ 2005-01-21 14:31 ` mmikucionis at gmail dot com
  2005-01-21 14:36 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: mmikucionis at gmail dot com @ 2005-01-21 14:31 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mmikucionis at gmail dot com  2005-01-21 14:31 -------
my last comment was close to this bug:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18926
sorry

-- 


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


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

* [Bug c/19435] spurious warnings with nested array constructors
  2005-01-14  3:08 [Bug c/19435] New: spurious warnings with nested array constructors rfeany at mrv dot com
                   ` (2 preceding siblings ...)
  2005-01-21 14:31 ` mmikucionis at gmail dot com
@ 2005-01-21 14:36 ` pinskia at gcc dot gnu dot org
  2005-02-01 23:04 ` jsm28 at gcc dot gnu dot org
  2005-04-14 22:25 ` jsm28 at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-21 14:36 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-01-21 14:36 -------
(In reply to comment #2)
> I have very similar situation but with even worse results:

The C++ problem is recorded in a different bug (that might have been my fault for not testing the C++ 
front-end), see PR 18327.

-- 


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


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

* [Bug c/19435] spurious warnings with nested array constructors
  2005-01-14  3:08 [Bug c/19435] New: spurious warnings with nested array constructors rfeany at mrv dot com
                   ` (3 preceding siblings ...)
  2005-01-21 14:36 ` pinskia at gcc dot gnu dot org
@ 2005-02-01 23:04 ` jsm28 at gcc dot gnu dot org
  2005-04-14 22:25 ` jsm28 at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2005-02-01 23:04 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jsm28 at gcc dot gnu dot org  2005-02-01 23:04 -------
Testing a patch.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jsm28 at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2005-01-14 03:13:57         |2005-02-01 23:04:14
               date|                            |


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


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

* [Bug c/19435] spurious warnings with nested array constructors
  2005-01-14  3:08 [Bug c/19435] New: spurious warnings with nested array constructors rfeany at mrv dot com
                   ` (4 preceding siblings ...)
  2005-02-01 23:04 ` jsm28 at gcc dot gnu dot org
@ 2005-04-14 22:25 ` jsm28 at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2005-04-14 22:25 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jsm28 at gcc dot gnu dot org  2005-04-14 22:25 -------
*** Bug 21033 has been marked as a duplicate of this bug. ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |acct4290 at dedion dot com


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


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

end of thread, other threads:[~2005-04-14 22:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-14  3:08 [Bug c/19435] New: spurious warnings with nested array constructors rfeany at mrv dot com
2005-01-14  3:14 ` [Bug c/19435] " pinskia at gcc dot gnu dot org
2005-01-21 13:37 ` mmikucionis at gmail dot com
2005-01-21 14:31 ` mmikucionis at gmail dot com
2005-01-21 14:36 ` pinskia at gcc dot gnu dot org
2005-02-01 23:04 ` jsm28 at gcc dot gnu dot org
2005-04-14 22:25 ` 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).