public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/35387]  New: __PRETTY_FUNCTION__ produces inconsistent output
@ 2008-02-27  8:52 d dot frey at gmx dot de
  2008-02-27  9:35 ` [Bug c++/35387] " rguenth at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: d dot frey at gmx dot de @ 2008-02-27  8:52 UTC (permalink / raw)
  To: gcc-bugs

Minimal example program:

#include <iostream>
#include <algorithm>

template< typename T > struct A;

template< typename T, typename U > struct A< std::pair< T, U > >
{
  static void f()
  {
    std::cout << __PRETTY_FUNCTION__ << std::endl;
  }
};

int main()
{
  A< std::pair< int, int > >::f();
}


Output of __PRETTY_FUNCTION__ from this program:

static void A<std::pair<_T1, _T2> >::f() [with T = int, U = int]

Problem:

_T1 and _T2 are printed as the pair's parameter names, but it then say T=int
and U=int.

Additional information:

This only seems to occur with partial specialization.


-- 
           Summary: __PRETTY_FUNCTION__ produces inconsistent output
           Product: gcc
           Version: 4.2.1
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: d dot frey at gmx dot de


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


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

* [Bug c++/35387] __PRETTY_FUNCTION__ produces inconsistent output
  2008-02-27  8:52 [Bug c++/35387] New: __PRETTY_FUNCTION__ produces inconsistent output d dot frey at gmx dot de
@ 2008-02-27  9:35 ` rguenth at gcc dot gnu dot org
  2008-02-27 12:03 ` d dot frey at gmx dot de
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-02-27  9:35 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2008-02-27 09:35 -------
It uses the names as in the std::pair template declaration, so you could argue
this is correct.


-- 


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


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

* [Bug c++/35387] __PRETTY_FUNCTION__ produces inconsistent output
  2008-02-27  8:52 [Bug c++/35387] New: __PRETTY_FUNCTION__ produces inconsistent output d dot frey at gmx dot de
  2008-02-27  9:35 ` [Bug c++/35387] " rguenth at gcc dot gnu dot org
@ 2008-02-27 12:03 ` d dot frey at gmx dot de
  2008-02-27 13:01 ` manu at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: d dot frey at gmx dot de @ 2008-02-27 12:03 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 939 bytes --]



------- Comment #2 from d dot frey at gmx dot de  2008-02-27 12:02 -------
I understand where the names come from, but that doesn't make the message
correct. Consider the specialization in the example program to use <_T2,_T1>
(note the reversed order) and an instantiation with <int,double>, the resulting
message is:

static void A<std::pair<_T1, _T2> >::f() [with _T2 = int, _T1 = double]

which is *really* misleading. Since it's actually vice versa.

Additionally I just found out that the same problem also occurs within error
and warning messages from the compiler, so it's not limited to
__PRETTY_FUNCTION__. I triggered a warning for an unused variable, which reads:

foo.cpp: In static member function ‘static void A<std::pair<_T1, _T2> >::f()
[with T = int, U = int]’:
foo.cpp:17:   instantiated from here
foo.cpp:10: warning: unused variable ‘i’

Regards, Daniel


-- 


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


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

* [Bug c++/35387] __PRETTY_FUNCTION__ produces inconsistent output
  2008-02-27  8:52 [Bug c++/35387] New: __PRETTY_FUNCTION__ produces inconsistent output d dot frey at gmx dot de
  2008-02-27  9:35 ` [Bug c++/35387] " rguenth at gcc dot gnu dot org
  2008-02-27 12:03 ` d dot frey at gmx dot de
@ 2008-02-27 13:01 ` manu at gcc dot gnu dot org
  2008-02-27 21:59 ` d dot frey at gmx dot de
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: manu at gcc dot gnu dot org @ 2008-02-27 13:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from manu at gcc dot gnu dot org  2008-02-27 13:00 -------
Confirmed. This is a diagnostics bug. (And perhaps a duplicate).

Thanks for the report. If you would like to contribute a patch, please read 
http://gcc.gnu.org/contribute.html


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu dot org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |diagnostic
   Last reconfirmed|0000-00-00 00:00:00         |2008-02-27 13:00:51
               date|                            |


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


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

* [Bug c++/35387] __PRETTY_FUNCTION__ produces inconsistent output
  2008-02-27  8:52 [Bug c++/35387] New: __PRETTY_FUNCTION__ produces inconsistent output d dot frey at gmx dot de
                   ` (2 preceding siblings ...)
  2008-02-27 13:01 ` manu at gcc dot gnu dot org
@ 2008-02-27 21:59 ` d dot frey at gmx dot de
  2008-02-27 22:46 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: d dot frey at gmx dot de @ 2008-02-27 21:59 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1660 bytes --]



------- Comment #4 from d dot frey at gmx dot de  2008-02-27 21:58 -------
More information:

I checked out the trunk and checked it again. The bug is still present, but
while testing it, I noticed that the problem does not occur with my own types,
only with types from the standard library. Here's the code I used:

#include <algorithm>

template< typename X, typename Y > struct P {};

template< typename > struct A;

template< typename T, typename U >
struct A< P< T, U > >
{ static void f() { int i; } };

template< typename V, typename W >
struct A< std::pair< V, W > >
{ static void f() { int i; } };

int main()
{
  A< P< int, double > >::f();
  A< std::pair< int, double > >::f();
}

and the output is:

frey@fiasko:~/work/test/foo$
/home/frey/work/svn/gcc/host-i686-pc-linux-gnu/gcc/g++
-B/home/frey/work/svn/gcc/host-i686-pc-linux-gnu/gcc/ -ansi -pedantic -Wall
-Wextra 
-I/home/frey/work/svn/gcc/i686-pc-linux-gnu/libstdc++-v3/include/i686-pc-linux-gnu
-I/home/frey/work/svn/gcc/i686-pc-linux-gnu/libstdc++-v3/include
-I/home/frey/work/svn/gcc/libstdc++-v3/libsupc++ foo.cpp -c -o foo
foo.cpp: In static member function ‘static void A<P<T, U> >::f() [with T = int,
U = double]’:
foo.cpp:12:   instantiated from here
foo.cpp:7: warning: unused variable ‘i’
foo.cpp: In static member function ‘static void A<std::pair<_T1, _T2> >::f()
[with V = int, W = double]’:
foo.cpp:13:   instantiated from here
foo.cpp:8: warning: unused variable ‘i’
frey@fiasko:~/work/test/foo$
/home/frey/work/svn/gcc/host-i686-pc-linux-gnu/gcc/g++ --version
g++ (GCC) 4.4.0 20080227 (experimental)
[snip]


-- 


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


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

* [Bug c++/35387] __PRETTY_FUNCTION__ produces inconsistent output
  2008-02-27  8:52 [Bug c++/35387] New: __PRETTY_FUNCTION__ produces inconsistent output d dot frey at gmx dot de
                   ` (3 preceding siblings ...)
  2008-02-27 21:59 ` d dot frey at gmx dot de
@ 2008-02-27 22:46 ` pinskia at gcc dot gnu dot org
  2008-02-28  8:15 ` d dot frey at gmx dot de
  2008-02-28 17:08 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-02-27 22:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from pinskia at gcc dot gnu dot org  2008-02-27 22:45 -------
This is most likely a dup of bug 99.


-- 


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


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

* [Bug c++/35387] __PRETTY_FUNCTION__ produces inconsistent output
  2008-02-27  8:52 [Bug c++/35387] New: __PRETTY_FUNCTION__ produces inconsistent output d dot frey at gmx dot de
                   ` (4 preceding siblings ...)
  2008-02-27 22:46 ` pinskia at gcc dot gnu dot org
@ 2008-02-28  8:15 ` d dot frey at gmx dot de
  2008-02-28 17:08 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: d dot frey at gmx dot de @ 2008-02-28  8:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from d dot frey at gmx dot de  2008-02-28 08:14 -------
I looked at bug #99, but I am unsure whether this bug is really a dup of it.
#99 is about overloads and occurs with user types, while this bug is about
partial template specializations and occurs only with certain types from the
STL.


-- 


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


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

* [Bug c++/35387] __PRETTY_FUNCTION__ produces inconsistent output
  2008-02-27  8:52 [Bug c++/35387] New: __PRETTY_FUNCTION__ produces inconsistent output d dot frey at gmx dot de
                   ` (5 preceding siblings ...)
  2008-02-28  8:15 ` d dot frey at gmx dot de
@ 2008-02-28 17:08 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-02-28 17:08 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from pinskia at gcc dot gnu dot org  2008-02-28 17:07 -------
No, bug 99 has specialization too:

 template<unsigned int n, unsigned int m>
   double ch(dummy<n>, dummy<m>);

 template<unsigned int n>
   double ch(dummy<n>, dummy<0>);

 template<unsigned int m>
   double ch(dummy<0>, dummy<m>);

Those are all specialization of the first one, not overloaded functions.

See also comment #11.

*** This bug has been marked as a duplicate of 99 ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


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


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

end of thread, other threads:[~2008-02-28 17:08 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-27  8:52 [Bug c++/35387] New: __PRETTY_FUNCTION__ produces inconsistent output d dot frey at gmx dot de
2008-02-27  9:35 ` [Bug c++/35387] " rguenth at gcc dot gnu dot org
2008-02-27 12:03 ` d dot frey at gmx dot de
2008-02-27 13:01 ` manu at gcc dot gnu dot org
2008-02-27 21:59 ` d dot frey at gmx dot de
2008-02-27 22:46 ` pinskia at gcc dot gnu dot org
2008-02-28  8:15 ` d dot frey at gmx dot de
2008-02-28 17:08 ` 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).