This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/10541: template <char * w_val > does not work
- From: gianni at mariani dot ws
- To: gcc-gnats at gcc dot gnu dot org
- Date: 29 Apr 2003 16:16:50 -0000
- Subject: c++/10541: template <char * w_val > does not work
- Reply-to: gianni at mariani dot ws
>Number: 10541
>Category: c++
>Synopsis: template <char * w_val > does not work
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Apr 29 16:26:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: gianni at mariani dot ws
>Release: GCC 3.2.2
>Organization:
>Environment:
Linux RH 8.0
configure --enable-shared --enable-threads=posix --disable-checking --host=i386-redhat-linux --with-system-zlib --enable-__cxa_atexit
Thread model: posix
gcc version 3.2.2
>Description:
g++ gives a number of errors to the code below. As far as I can tell it's legal C++.
g++ tt6.cpp -o tt6
tt6.cpp:43: could not convert template argument `0' to `char*'
tt6.cpp:43: ISO C++ forbids declaration of `m_cstr' with no type
tt6.cpp:45: `0' is not a valid template argument
tt6.cpp:45: it must be the address of an object with external linkage
tt6.cpp:45: ISO C++ forbids declaration of `m_cstr_c' with no type
tt6.cpp:47: `tester::m_static' is not a valid template argument
tt6.cpp:47: it must be the address of an object with external linkage
tt6.cpp:47: ISO C++ forbids declaration of `m_cstr_s' with no type
make: *** [tt6] Error 1
#include <cassert>
template < char * w_val >
class IType
{
public:
char * m_value;
inline IType()
: m_value( w_val )
{
}
inline operator char * & ()
{
return m_value;
}
inline operator const char * & () const
{
return m_value;
}
inline char * & operator = ( const char * & i_value )
{
m_value = i_value;
return m_value;
}
};
class tester
{
public:
const static char * m_static;
IType<0> m_cstr;
IType<static_cast<char *>( 0 )> m_cstr_c;
IType<m_static> m_cstr_s;
};
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: