public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/17161] New: failure to diagnose an ill-formed instantiation on a local type
@ 2004-08-24  0:42 sebor at roguewave dot com
  2004-08-24  0:46 ` [Bug c++/17161] " pinskia at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: sebor at roguewave dot com @ 2004-08-24  0:42 UTC (permalink / raw)
  To: gcc-bugs

Gcc 3.4 fails to diagnose the following ill-formed program.

$ cat t.cpp && g++ --version && g++ t.cpp -Wextra -W -pedantic
struct S {
    void foo (unsigned long) { }
    template <class T> void foo (T) { }
};

int main ()
{
    enum E { e };

    S ().foo (e);   // local types are not allowed as template arguments
}

g++ (GCC) 3.4.0
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

-- 
           Summary: failure to diagnose an ill-formed instantiation on a
                    local type
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sebor at roguewave dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: all
  GCC host triplet: all
GCC target triplet: all


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


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

* [Bug c++/17161] failure to diagnose an ill-formed instantiation on a local type
  2004-08-24  0:42 [Bug c++/17161] New: failure to diagnose an ill-formed instantiation on a local type sebor at roguewave dot com
@ 2004-08-24  0:46 ` pinskia at gcc dot gnu dot org
  2004-08-24  0:59 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-24  0:46 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-08-24 00:46 -------
hmm, it chooses unsigned long version of foo.

-- 


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


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

* [Bug c++/17161] failure to diagnose an ill-formed instantiation on a local type
  2004-08-24  0:42 [Bug c++/17161] New: failure to diagnose an ill-formed instantiation on a local type sebor at roguewave dot com
  2004-08-24  0:46 ` [Bug c++/17161] " pinskia at gcc dot gnu dot org
@ 2004-08-24  0:59 ` pinskia at gcc dot gnu dot org
  2004-08-24  3:02 ` bangerth at dealii dot org
  2005-02-22 10:25 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-24  0:59 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-08-24 00:59 -------
Confirmed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |accepts-invalid
   Last reconfirmed|0000-00-00 00:00:00         |2004-08-24 00:59:03
               date|                            |


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


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

* [Bug c++/17161] failure to diagnose an ill-formed instantiation on a local type
  2004-08-24  0:42 [Bug c++/17161] New: failure to diagnose an ill-formed instantiation on a local type sebor at roguewave dot com
  2004-08-24  0:46 ` [Bug c++/17161] " pinskia at gcc dot gnu dot org
  2004-08-24  0:59 ` pinskia at gcc dot gnu dot org
@ 2004-08-24  3:02 ` bangerth at dealii dot org
  2005-02-22 10:25 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: bangerth at dealii dot org @ 2004-08-24  3:02 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-08-24 03:02 -------
Funny, actually. Consider this case: 
--------------- 
struct S { 
    void foo (unsigned long); 
    template <class T> void foo (T); 
}; 
 
enum E1 { e1 }; 
 
int main () 
{ 
  enum E2 { e2 }; 
  S().foo (e1); 
  S().foo (e2); 
} 
--------------------- 
Compiled with 3.4 and mainline, let's inspect the symbols: 
 
g/x> nm -C x.o 
         U __gxx_personality_v0 
00000000 T main 
         U S::foo(unsigned long) 
         U void S::foo<E1>(E1) 
 
So it uses the unsigned int version for the local type, and the template 
version for the global type. On could even make a case for this behavior 
(although I think that this is not the intent of the standard): since E2 
is a local type, it can't match the template function, which is therefore 
removed from the overload set, and the compiler then makes the conversion 
to unsigned long. Note that indeed the compiler says that there is no 
match if the non-template version of S::foo is removed, which would be 
consistent with this behavior. 
 
W. 
 

-- 


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


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

* [Bug c++/17161] failure to diagnose an ill-formed instantiation on a local type
  2004-08-24  0:42 [Bug c++/17161] New: failure to diagnose an ill-formed instantiation on a local type sebor at roguewave dot com
                   ` (2 preceding siblings ...)
  2004-08-24  3:02 ` bangerth at dealii dot org
@ 2005-02-22 10:25 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-02-22 10:25 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-02-22 01:42 -------
This has now been fixed:

t.cc: In function 'int main()':
t.cc:10: error: 'main()::E' uses local type 'main()::E'
t.cc:10: error:   trying to instantiate 'template<class T> void S::foo(T)'

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.0.0


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


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

end of thread, other threads:[~2005-02-22  1:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-24  0:42 [Bug c++/17161] New: failure to diagnose an ill-formed instantiation on a local type sebor at roguewave dot com
2004-08-24  0:46 ` [Bug c++/17161] " pinskia at gcc dot gnu dot org
2004-08-24  0:59 ` pinskia at gcc dot gnu dot org
2004-08-24  3:02 ` bangerth at dealii dot org
2005-02-22 10:25 ` pinskia at gcc dot gnu dot 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).