public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/52460] New: Misleading error message with templated c++ code
@ 2012-03-02  9:05 petschy at gmail dot com
  2012-03-02  9:31 ` [Bug c++/52460] " redi at gcc dot gnu.org
  2021-08-04  6:31 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: petschy at gmail dot com @ 2012-03-02  9:05 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 52460
           Summary: Misleading error message with templated c++ code
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: petschy@gmail.com


compiling the following:

---8<---8<---8<---8<---
template<typename T>
struct Base
{
        typename T::Type        var;
};
template<typename U>
struct Derived : Base<Derived<U> >
{
        typedef U       Type;
};
void foo()
{
        Derived<int> i;
}
---8<---8<---8<---8<---

gives the error

gcctempl.cpp: In instantiation of ‘struct Base<Derived<int> >’:
gcctempl.cpp:7:8:   required from ‘struct Derived<int>’
gcctempl.cpp:13:15:   required from here
gcctempl.cpp:4:19: error: no type named ‘Type’ in ‘struct Derived<int>’

on all tested gcc versions (4.4, 4.5, 4.6, 4.7). 

There is definitely a type called 'Type' in struct 'Derived', hence the error
message is misleading.

 I'm not sure, the above code is probably ill-formed, because it creates a
circular dependence between the two types, but then, this should be
communicated to the user.


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

* [Bug c++/52460] Misleading error message with templated c++ code
  2012-03-02  9:05 [Bug c++/52460] New: Misleading error message with templated c++ code petschy at gmail dot com
@ 2012-03-02  9:31 ` redi at gcc dot gnu.org
  2021-08-04  6:31 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2012-03-02  9:31 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-03-02
     Ever Confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-03-02 09:30:46 UTC ---
Clang gives a very similar error but Comeau gives a better one:

"ComeauTest.c", line 4: error: incomplete type is not allowed
          typename T::Type        var;
                   ^
          detected during:
            instantiation of class "Base<T> [with T=Derived<int>]" at line 7
            instantiation of class "Derived<U> [with U=int]" at line 13


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

* [Bug c++/52460] Misleading error message with templated c++ code
  2012-03-02  9:05 [Bug c++/52460] New: Misleading error message with templated c++ code petschy at gmail dot com
  2012-03-02  9:31 ` [Bug c++/52460] " redi at gcc dot gnu.org
@ 2021-08-04  6:31 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-04  6:31 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2012-03-02 00:00:00         |2021-8-3

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #1)
> Clang gives a very similar error but Comeau gives a better one:
Even MSVC gives a very similar error message as GCC.

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

end of thread, other threads:[~2021-08-04  6:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-02  9:05 [Bug c++/52460] New: Misleading error message with templated c++ code petschy at gmail dot com
2012-03-02  9:31 ` [Bug c++/52460] " redi at gcc dot gnu.org
2021-08-04  6:31 ` pinskia 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).