🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #847

poor error reporting

#847
From: Raul Deluth Rockwell
Date: Tue, 05 Dec 1989 22:58
59 lines
2210 bytes
(gcc  version 1.36, running on sun-sparc)

often, when setting up a static array, or large static structure, one
encounters an error because one of the arguments was specified incorrectly.
gcc is most unhelpful here, as it reports these errors as occuring at
the END of the declation, rather than reporting the actual line on
which the error occurred.

For example, the following program yields the error:
test.c:27: type mismatch in initialization

/* line 1 */
#include <stdio.h>

typedef union a 
{
    unsigned long foo;
    signed char bar;
    union a * bletch;
} A;

typedef struct b
{
    int one;
    char *two;
    A three;
    char four;
    struct b* five;
} B;

B good = 
{
    1,				/* (int) */
    "two",			/* (char*) */
    0,				/* (union) */
    '4',			/* (char) */
    NULL,			/* (B*) */
}; /************ line 27 ********************/

main() {} 

----------------------------------------------------------------------

One can get other errors reported at the wrong line (such as
non-constant initializers to static variables) and as far as I know,
the only way to localize them is to recompile the program n times
where n is the number of guesses you have to make about which
element(s) are bad.  [I'm not trying to invite a discussion here about
guessing strategies.]

Finally, I thought that one was supposed to be able to initialize a
union (the first element of the union).  Anybody want to correct me on
this?  (That is the 'error' which the compiler appears to be stuck
on.)

Raul Rockwell
INTERNET:   raulmill@usc.edu                       !
UUCP:       ...uunet!usc!raulmill                  !  55 mph = 82 nc
U.S.SNAIL:  721 E Windsor #4,  GLENDALE CA  91205  !
Technical Details
Message-ID: <8912052258.AA20077@koh-sun1.usc.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!uunet!bu-cs!lll-winken!brutus.cs.uiuc.edu!samsung!cs.utexas.edu!tut.cis.ohio-state.edu!USC.EDU!raulmill%koh-sun1.usc.edu

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!uunet!bu-cs!lll-winken!brutus.cs.uiuc.edu!samsung!cs.utexas.edu!tut.cis.ohio-state.edu!USC.EDU!raulmill%koh-sun1.usc.edu
From: raulmill%koh-sun1.usc.edu@USC.EDU (Raul Deluth Rockwell)
Newsgroups: gnu.gcc.bug
Subject: poor error reporting
Message-ID: <8912052258.AA20077@koh-sun1.usc.edu>
Date: 5 Dec 89 22:58:50 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 59