public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/59254] New: confusing diagnostic for undefined template shadowed by declaration in inline namespace
@ 2013-11-22 15:29 redi at gcc dot gnu.org
  2015-03-23 15:17 ` [Bug c++/59254] " redi at gcc dot gnu.org
  2020-07-29 13:37 ` redi at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2013-11-22 15:29 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 59254
           Summary: confusing diagnostic for undefined template shadowed
                    by declaration in inline namespace
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org

namespace outer {
  inline namespace inner {
#ifndef OK
    template<typename T> struct A;
#endif
  }

  template<typename T> struct A;

  template class A<int>;
}

This gives a confusing diagnostic:

$ g++ -std=gnu++11 n.cc -c
n.cc:10:18: error: ‘A’ is not a class template
   template class A<int>;
                  ^
n.cc:10:18: error: template argument required for ‘class A’


That's particularly confusing because A is a class template, and so is inner::A
(although if it's just a class type the error is the same) and because a
template argument is given.


Without the previous definition in the inline namespace we get the expected
explanation:

$ g++ -std=gnu++11 n.cc -c -DOK
n.cc:10:18: error: explicit instantiation of ‘class outer::A<int>’ before
definition of template
   template class A<int>;
                  ^
>From gcc-bugs-return-435547-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Nov 22 15:38:31 2013
Return-Path: <gcc-bugs-return-435547-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 27352 invoked by alias); 22 Nov 2013 15:38:31 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 27265 invoked by uid 48); 22 Nov 2013 15:38:27 -0000
From: "rearnsha at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/59216] [4.9 Regression] ARM negdi*extendsidi regression
Date: Fri, 22 Nov 2013 15:38:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: target
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords: wrong-code
X-Bugzilla-Severity: normal
X-Bugzilla-Who: rearnsha at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P1
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 4.9.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status cf_reconfirmed_on everconfirmed
Message-ID: <bug-59216-4-NbRV7pU9IO@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-59216-4@http.gcc.gnu.org/bugzilla/>
References: <bug-59216-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-11/txt/msg02324.txt.bz2
Content-length: 507

http://gcc.gnu.org/bugzilla/show_bug.cgi?idY216

Richard Earnshaw <rearnsha at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-11-22
     Ever confirmed|0                           |1

--- Comment #3 from Richard Earnshaw <rearnsha at gcc dot gnu.org> ---
Confirmed, patch forthcoming.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/59254] confusing diagnostic for undefined template shadowed by declaration in inline namespace
  2013-11-22 15:29 [Bug c++/59254] New: confusing diagnostic for undefined template shadowed by declaration in inline namespace redi at gcc dot gnu.org
@ 2015-03-23 15:17 ` redi at gcc dot gnu.org
  2020-07-29 13:37 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2015-03-23 15:17 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-03-23
     Ever confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Confirmed on trunk.

The difference between 'struct' and 'class' in my original example is not
relevant:

namespace outer {
  inline namespace inner {
    template<typename T> struct A;
  }

  template<typename T> struct A;

  template struct A<int>;
}


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/59254] confusing diagnostic for undefined template shadowed by declaration in inline namespace
  2013-11-22 15:29 [Bug c++/59254] New: confusing diagnostic for undefined template shadowed by declaration in inline namespace redi at gcc dot gnu.org
  2015-03-23 15:17 ` [Bug c++/59254] " redi at gcc dot gnu.org
@ 2020-07-29 13:37 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2020-07-29 13:37 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2015-03-23 00:00:00         |2020-7-29

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
If I add a declaration of an explicit specialization A<long> we get another
unhelpful error:

namespace outer {
  inline namespace inner {
    template<typename T> struct A;
  }

  template<typename T> struct A;

  template struct A<int>;

  template<> struct A<long>;
}

n.cc:8:19: error: 'A' is not a class template
    8 |   template struct A<int>;
      |                   ^
n.cc:8:19: error: template argument required for 'struct A'
n.cc:10:21: error: 'A' is not a class template
   10 |   template<> struct A<long>;
      |                     ^
n.cc:10:21: error: template specifiers not specified in declaration of
'template<class T> struct outer::A'


I have no idea what "template specifiers not specified in declaration" means.

Clang is more clear about the problem (the class template is declared twice and
so causes ambiguities):


n.cc:8:19: error: reference to 'A' is ambiguous
  template struct A<int>;
                  ^
n.cc:6:31: note: candidate found by name lookup is 'outer::A'
  template<typename T> struct A;
                              ^
n.cc:3:33: note: candidate found by name lookup is 'outer::inner::A'
    template<typename T> struct A;
                                ^
n.cc:8:19: error: explicit instantiation of undefined template 'outer::A<int>'
  template struct A<int>;
                  ^
n.cc:6:31: note: template is declared here
  template<typename T> struct A;
                              ^
n.cc:10:21: error: reference to 'A' is ambiguous
  template<> struct A<long>;
                    ^
n.cc:6:31: note: candidate found by name lookup is 'outer::A'
  template<typename T> struct A;
                              ^
n.cc:3:33: note: candidate found by name lookup is 'outer::inner::A'
    template<typename T> struct A;
                                ^

EDG does well too:

"n.cc", line 8: error: "outer::A" is ambiguous
    template struct A<int>;
                    ^

"n.cc", line 8: error: invalid explicit instantiation declaration
    template struct A<int>;
             ^

"n.cc", line 10: error: "outer::A" is ambiguous
    template<> struct A<long>;
                      ^

3 errors detected in the compilation of "n.cc".

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-07-29 13:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-22 15:29 [Bug c++/59254] New: confusing diagnostic for undefined template shadowed by declaration in inline namespace redi at gcc dot gnu.org
2015-03-23 15:17 ` [Bug c++/59254] " redi at gcc dot gnu.org
2020-07-29 13:37 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).