Bug 84457 - gcc 2.96 segfaults when given bad struct initializer
gcc 2.96 segfaults when given bad struct initializer
Status: CLOSED CURRENTRELEASE
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
7.1
i686 Linux
low Severity low
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2003-02-17 13:18 EST by Allen Grace
Modified: 2005-10-31 17:00 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-10-03 08:09:32 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Allen Grace 2003-02-17 13:18:03 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1) Gecko/20020826

Description of problem:
Bug report 77350 describes a similar situation, where feeding a bad struct
initializer to gcc 2.96 causes an unspecified internal error.

However, I've experienced the same results with a different compiler version to
the one described therein. The reporter in that case said that gcc 2.9x was not
affected; this is not what I've seen. 

This problem is not serious in the slightest, because if I fix my code it stops
happening. 

########################
Sample code:

#include <stdlib.h>
 
struct innerstruct {
        const char * const * values;
} innerstruct;
 
struct outerstruct {
        const struct innerstruct *fields;
} list_of_things[] = {
        {
                /* if I mis-spell the name of the struct in the cast,
                 * the compiler exits unhappily */
                (const struct innerstruct_wrong []) {
                        {
                                (const char * const []) {
                                        "blah", NULL
                                }
                        },
                        {
                                NULL
                        }
                }
        },
        { NULL }
};
########################



Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1. save the provided sample code to a file
2. type 'gcc -c <file>'

    

Actual Results:  The compiler aborts with an error message asking me to submit a
bug report:

crashgcc.c:15: warning: excess elements in struct initializer
crashgcc.c:15: warning: (near initialization for `(anonymous)[0]')
crashgcc.c:18: warning: excess elements in struct initializer
crashgcc.c:18: warning: (near initialization for `(anonymous)[1]')
crashgcc.c:20: warning: initialization from incompatible pointer type
crashgcc.c:22: Internal error: Segmentation fault.
Please submit a full bug report.
See <URL:http://bugzilla.redhat.com/bugzilla/> for instructions.

Expected Results:  

Something similar to the above, perhaps with a warning about a struct type being
declared inside the initializer, and without the bit about the segmentation fault. 

Additional info:
Comment 1 Richard Henderson 2004-10-03 08:09:32 EDT
No ICE with gcc 3.2.3-20.

Note You need to log in before you can comment on or make changes to this bug.