public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* Maybe a bug in G++
@ 2004-07-18 17:40 Sven Gohlke
2004-07-18 18:18 ` Andrew Pinski
0 siblings, 1 reply; 2+ messages in thread
From: Sven Gohlke @ 2004-07-18 17:40 UTC (permalink / raw)
To: gcc-bugs
[-- Attachment #1: Type: Text/Plain, Size: 673 bytes --]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello,
I think I have found an identifier lookup bug in g++ (GCC) 3.3.3 (Debian
20040422). Attached are two files, one which compiles and one which doesn't
though I think that it should compile.
But since I have found a workaround (or maybe a standard conforming
solution) ...
- --
Best Regards
Sven Gohlke
GnuPG Fingerprint: 7197 61F6 AFDE F46D 914B 65C2 2A4B 5BBF 6CC0
at hkp://wwwkeys.pgp.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iEYEARECAAYFAkD6s5wACgkQZcIqS1u/bMCsswCfQxYoW40o3e4Ju0c5sgYi57BD
XeQAnAuZywdEymg2MqLuuuVUm9K3S19L
=IV24
-----END PGP SIGNATURE-----
[-- Attachment #2: compiles-not.cc --]
[-- Type: text/x-c++src, Size: 1706 bytes --]
#include <iostream>
template<typename _T>
struct _TypeOf_
{
friend class _Null_;
private:
template<int, typename _1>
struct H
{
typedef typename _1::Type Type;
};
template<typename _1>
struct H<0, _1>
{
typedef _1 Type;
};
typedef char HasType;
typedef struct { char _[2]; } NoType;
template<typename _1> static NoType test (...);
template<typename _1> static HasType test (typename _1::Type const*);
public:
typedef typename
H<sizeof(test<_T>(0))==sizeof(HasType), _T>::Type Type;
};
template<typename _T1, typename _T2>
struct _IsIdentical_
{
enum { Value = 0 };
};
template<typename _T1>
struct _IsIdentical_<_T1, _T1>
{
enum { Value = 1 };
};
/*
* First test type
*
* has an empty member type Type
*/
struct ItHas
{
struct Type{};
};
/*
* Second test type
*
* has a member type Type identical to ItHas::Type
*/
struct ItHasNot
{
typedef ItHas::Type Type;
};
/*
* Third test type
*/
typedef int Other;
int
main (int argc, const char **argv)
{
/* Both test are made at compile time. No calculations are made at run
* time. The first calculation results to 0, the second to 1.
*/
std::cout << "_IsIdentical_<ItHas, ItHasNot>: " <<
_IsIdentical_<ItHas, ItHasNot>::Value << std::endl;
std::cout << "_IsIdentical_<ItHas, Other>: " <<
_IsIdentical_<ItHas, Other>::Value << std::endl;
std::cout <<
"_IsIdentical_<_TypeOf_<ItHas>::Type, _TypeOf_<ItHasNot>::Type>: " <<
_IsIdentical_<_TypeOf_<ItHas>::Type, _TypeOf_<ItHasNot>::Type>::Value <<
std::endl;
std::cout <<
"_IsIdentical_<_TypeOf_<ItHas>::Type, _TypeOf_<Other>::Type>: " <<
_IsIdentical_<_TypeOf_<ItHas>::Type, _TypeOf_<Other>::Type>::Value <<
std::endl;
return 0;
}
[-- Attachment #3: compiles.cc --]
[-- Type: text/x-c++src, Size: 1737 bytes --]
#include <iostream>
template<typename _T>
struct _TypeOf_
{
friend class _Null_;
private:
template<int, typename _1>
struct H
{
typedef typename _1::Type Type;
};
template<typename _1>
struct H<0, _1>
{
typedef _1 Type;
};
typedef char HasType;
typedef struct { char _[2]; } NoType;
template<typename _1> static NoType test (...);
template<typename _1> static HasType test (typename _1::Type const*);
typedef _TypeOf_ This;
public:
typedef typename
H<sizeof(This::test<_T>(0))==sizeof(HasType), _T>::Type Type;
};
template<typename _T1, typename _T2>
struct _IsIdentical_
{
enum { Value = 0 };
};
template<typename _T1>
struct _IsIdentical_<_T1, _T1>
{
enum { Value = 1 };
};
/*
* First test type
*
* has an empty member type Type
*/
struct ItHas
{
struct Type{};
};
/*
* Second test type
*
* has a member type Type identical to ItHas::Type
*/
struct ItHasNot
{
typedef ItHas::Type Type;
};
/*
* Third test type
*/
typedef int Other;
int
main (int argc, const char **argv)
{
/* Both test are made at compile time. No calculations are made at run
* time. The first calculation results to 0, the second to 1.
*/
std::cout << "_IsIdentical_<ItHas, ItHasNot>: " <<
_IsIdentical_<ItHas, ItHasNot>::Value << std::endl;
std::cout << "_IsIdentical_<ItHas, Other>: " <<
_IsIdentical_<ItHas, Other>::Value << std::endl;
std::cout <<
"_IsIdentical_<_TypeOf_<ItHas>::Type, _TypeOf_<ItHasNot>::Type>: " <<
_IsIdentical_<_TypeOf_<ItHas>::Type, _TypeOf_<ItHasNot>::Type>::Value <<
std::endl;
std::cout <<
"_IsIdentical_<_TypeOf_<ItHas>::Type, _TypeOf_<Other>::Type>: " <<
_IsIdentical_<_TypeOf_<ItHas>::Type, _TypeOf_<Other>::Type>::Value <<
std::endl;
return 0;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Maybe a bug in G++
2004-07-18 17:40 Maybe a bug in G++ Sven Gohlke
@ 2004-07-18 18:18 ` Andrew Pinski
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Pinski @ 2004-07-18 18:18 UTC (permalink / raw)
To: Sven Gohlke; +Cc: gcc-bugs
On Jul 18, 2004, at 10:30 AM, Sven Gohlke wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hello,
>
> I think I have found an identifier lookup bug in g++ (GCC) 3.3.3
> (Debian
> 20040422). Attached are two files, one which compiles and one which
> doesn't
> though I think that it should compile.
Yes this is a bug in 3.3.x and before but it has been fixed in 3.4.0
and newer.
Thanks,
Andrew Pinski
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-07-18 18:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-18 17:40 Maybe a bug in G++ Sven Gohlke
2004-07-18 18:18 ` Andrew Pinski
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).