This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

C++ compile -vs- errors in structure definition


I'm using a fairly recent (last couple of weeks) g++ from the cvs
repository (head branch).

Consider this incorrect program:

================================================================
typedef int (*fptr) (void);

extern int func1 (void);
extern int func2 (int);

struct ts
{
  fptr one;
  fptr two;
};

ts the_ts =
{
  func2,
  func1
};
================================================================

If I compile this, I expect to get an error about the use of `func2'
in the `the_ts' structure.  I do get such an error, but the line
number is wrong:

    creche. g++ -fsyntax-only foo.cc 
    foo.cc:16: cannot convert `int (*) (int)' to `int (*) ()' in initialization

I expect line 14 and not 16.

If I have a very large structure (for instance, the structure used for
JNI has something like 100 function pointers in it), it becomes very
hard to find the actual incorrect line.

Tom

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]