[Bug c++/60615] New: bad location in error from initializer

tromey at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Mar 21 16:12:00 GMT 2014


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60615

            Bug ID: 60615
           Summary: bad location in error from initializer
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tromey at gcc dot gnu.org

Consider this source:

struct v
{
  int (*f1) (int);
  int (*f2) ();
  int (*f3) (int);
  int (*f4) (int);
};

int func(int x) { return x; }
int fv() { return 23; }

struct v inst = {
  func,
  func,
  func,
  func
}; // Line 17

Compile it with g++:

barimba. g++ --syntax-only pr.cc
pr.cc:17:1: error: invalid conversion from ‘int (*)(int)’ to ‘int (*)()’
[-fpermissive]
 }; // Line 17
 ^

Note that the error refers to line 17 and does not mention the field name
at all.  This is very inconvenient when one has a large struct of
function pointers -- it can be quite hard to find the actual location
of the problem.


More information about the Gcc-bugs mailing list