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++/80521] Wrong line reported in error for missing template argument in friend class declaration.


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80521

Alfred Agrell <blubban at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |blubban at gmail dot com

--- Comment #1 from Alfred Agrell <blubban at gmail dot com> ---
Ran into this one myself, reproduces on 6.3.0-12ubuntu2 and 8.0.0 20170427
Godbolt. Minimized testcase:


template<typename T>
class foo {
        int a;
        int b; // error here

        void c() {}

        /* template<typename> */ friend class bar; // error should be here
};

template<typename T> class bar {
        foo<int> baz;
};
template class bar<int>;


Expected output:

<source>: In instantiation of 'class foo<int>':
<source>:13:11:   required from here
<source>:9:40: error: template argument required for 'class bar'
        /* template<typename> */ friend class bar; // error should be here
                                              ^

Actual output:

<source>: In instantiation of 'class foo<int>':
<source>:13:11:   required from here
<source>:5:6: error: template argument required for 'class bar'
  int b; // error here
      ^

Clang output:

<source>:12:28: error: redefinition of 'bar' as different kind of symbol
template<typename T> class bar {
                           ^
<source>:9:40: note: previous definition is here
        /* template<typename> */ friend class bar; // error should be here
                                              ^

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