Bug 84457 - gcc 2.96 segfaults when given bad struct initializer
Summary: gcc 2.96 segfaults when given bad struct initializer
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
(Show other bugs)
Version: 7.1
Hardware: i686 Linux
low
low
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Brian Brock
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2003-02-17 18:18 UTC by Allen Grace
Modified: 2005-10-31 22:00 UTC (History)
0 users

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


Attachments (Terms of Use)

Description Allen Grace 2003-02-17 18:18:03 UTC
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 12:09:32 UTC
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.