Improper error synopsis in GCC 3.2.x

Anton Lavrentiev
Tue Apr 8 02:12:00 GMT 2003


Attached is a code fragment (C++) that causes GCC
to produce an error [which is correct] but with
wrong explanation.

struct stra {
  int a;

typedef struct {
  float b;
} strb;

int main(void)
  strb b;
  int a = b.stra;  // Line 12
  return a;

GCC's output follows:
a.cpp: In function `int main()':
a.cpp:12: invalid use of type decl `struct stra' as expression

To my understanding, if GCC complained that 'stra' is not
a member of 'strb' it would be more appropriate, like what
Sun's Workshop compiler produces:
"a.cpp", line 12: Error: stra is not a member of strb.
1 Error(s) detected.

Anton Lavrentiev
NCBI/NIH, Bethesda, MD

More information about the Gcc-bugs mailing list