[gnu.gcc.bug] poor error reporting

raulmill%koh-sun1.usc.edu@USC.EDU (Raul Deluth Rockwell) (12/06/89)

(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  !