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]
Other format: [Raw text]

[Bug c++/12390] New: Wrong line number for friend declaration of invalid template class


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: Wrong line number for friend declaration of invalid
                    template class
           Product: gcc
           Version: 3.4
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: minor
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: reichelt at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org

Consider the following invalid code snippet:

======================================================
template<typename> struct A
{
  int i;
  void foo();
  int j;
  void bar();

  template<int> friend struct A; // error
};

A<void> a;
======================================================

Compiling this with mainline I get:

bug.cc: In instantiation of `A<void>':
bug.cc:11:   instantiated from here
bug.cc:1: error: template parameter `class <template-parameter-1-1>'
bug.cc:5: error: redeclared here as `int <anonymous>'

The line number "5" is bogus, it should be "8" instead.
(It looks as if we issue the line number of the last data member.)
BTW, before 3.3 the line number was "2", which is also bogus.
But IMHO giving the beginning of the class definition is not as bad
as giving a wrong line from within.


In addition, line 3 of the error message changed w.r.t. 3.3 branch,
where it reads

bug.cc: In instantiation of `A<void>':
bug.cc:11:   instantiated from here
bug.cc:1: error: template parameter `class <anonymous template type parameter>'
bug.cc:5: error: redeclared here as `int <anonymous>'

I don't know whether this was on purpose or just by accident.


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