public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* is it a bug?
@ 2007-11-08 13:40 Patrick Lacasse
  2007-11-08 15:41 ` Rupert Wood
  0 siblings, 1 reply; 3+ messages in thread
From: Patrick Lacasse @ 2007-11-08 13:40 UTC (permalink / raw)
  To: gcc-help

[-- Attachment #1: Type: text/plain, Size: 249 bytes --]

Hi,

   Here is a sample code implementation of what I consider as being a bug in 
g++. Both g++ 4.1.1 and 4.2.2 have the same behaviour about this.
There is two lines which should do the same, but only one of the two works.

thanks
Patrick Lacasse

[-- Attachment #2: g++_bug.cpp --]
[-- Type: text/x-c++src, Size: 604 bytes --]

#include <iostream>
#include <typeinfo>

template< typename X >
struct A 
{
  typedef X X_type;
};

template< typename X >
void function( A<X> a,
	 //typename A<X>::X_type x )   // This line works. ( typedef workaround )
	 X x )                         // This line doesn't work.
{
  std::cout << "function(A<" << typeid(X).name() << ">," << x << ")" << std::endl;
}

int main()
{
  // This call works with and without the typedef workaround.
  function( A<double>(), 3.0 );

  // Implicit conversion from int to double 
  // will only occurs with the typedef workaround.
  function( A<double>(), 3 );
}

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

* RE: is it a bug?
  2007-11-08 13:40 is it a bug? Patrick Lacasse
@ 2007-11-08 15:41 ` Rupert Wood
  0 siblings, 0 replies; 3+ messages in thread
From: Rupert Wood @ 2007-11-08 15:41 UTC (permalink / raw)
  To: 'Patrick Lacasse'; +Cc: gcc-help

Patrick Lacasse wrote:

> Here is a sample code implementation of what I consider as being a
> bug in g++. Both g++ 4.1.1 and 4.2.2 have the same behaviour about
> this.

If you want to raise a bug about this you'll need to cite the parts of the C++ standard that prove what you're trying to do is legal. As another couple of data points g++ 4.3 and Comeau C++ reject this too.

IMO a better fix would be to specify the template argument on the function call, i.e.

    function<double>( A<double>(), 3 );

Rup.



______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________

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

* Is it a bug?
@ 2003-08-09 10:24 Lev Assinovsky
  0 siblings, 0 replies; 3+ messages in thread
From: Lev Assinovsky @ 2003-08-09 10:24 UTC (permalink / raw)
  To: gcc-bugs, gcc-help

Hi all!
I tried to build the following program in HP-UX 11.00 using gcc 3.2.3:
=============== cut here ====================
#include <string>
template<class CChar>
struct ACharTraits:
    public std::char_traits<CChar>
{
};

typedef char TCHAR;

std::basic_string<TCHAR, ACharTraits<TCHAR>, std::allocator<TCHAR> > s("aaaa");

int main()
{
    
}

================= cut here ==================

AND GOT:
-bash-2.05b$ g++ -o tstr tstr.cpp
/usr/ccs/bin/ld: Unsatisfied symbols:
   std::basic_string<char, ACharTraits<char>, std::allocator<char> >::_Rep::_S_terminal(first referenced in /var/tmp//cctBl474.o) (data)
   std::basic_string<char, ACharTraits<char>, std::allocator<char> >::_Rep::_S_max_size(first referenced in /var/tmp//cctBl474.o) (data)
collect2: ld returned 1 exit status

IS IT A BUG?

Sincerely, 

----
Lev Assinovsky
Aelita Software Corporation
O&S Core Division, Programmer
ICQ# 165072909

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

end of thread, other threads:[~2007-11-08 15:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-08 13:40 is it a bug? Patrick Lacasse
2007-11-08 15:41 ` Rupert Wood
  -- strict thread matches above, loose matches on Subject: below --
2003-08-09 10:24 Is " Lev Assinovsky

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).