This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/9338: ICE in peculiar templated constructors
- From: martin at xemacs dot org
- To: gcc-gnats at gcc dot gnu dot org
- Date: 16 Jan 2003 09:29:31 -0000
- Subject: c++/9338: ICE in peculiar templated constructors
- Reply-to: martin at xemacs dot org
>Number: 9338
>Category: c++
>Synopsis: ICE in peculiar templated constructors
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: ice-on-legal-code
>Submitter-Id: net
>Arrival-Date: Thu Jan 16 01:36:01 PST 2003
>Closed-Date:
>Last-Modified:
>Originator: Martin Buchholz
>Release: gcc-3.2.1
>Organization:
>Environment:
Linux x86
>Description:
The file below results in ICE
g++ main.cc -o main
main.cc: In function `int main(int, char**)':
main.cc:36: internal error: Segmentation fault
Please submit a full bug report,
The file compiles (with warnings) under icc,
but fails to link.
------------------------------------------------------
class Bool
{
public:
const bool val_;
template <class T, bool condition> struct Constraint;
template <class T> struct Constraint<T,true> { typedef int Dummy; };
template <typename T> struct Convertible { enum { value = true }; };
template <typename T>
explicit
Bool (T x, typename Constraint<T, Convertible<T>::value>::Dummy = 0)
: val_ (bool (x))
{}
template <class T> struct Unlikely { enum { value = false }; };
template <typename T>
explicit
Bool (T x, typename Constraint<T, ! Convertible<T>::value>::Dummy = 0);
template <typename T>
Bool (T x, typename Constraint<T, ! Unlikely<T>::value>::Dummy = 0);
Bool (bool val) : val_ (val) {}
Bool (const Bool & val) : val_ (bool (val)) {}
struct S_ { int M_; };
operator int S_::* () const { return val_ ? & S_::M_ : 0; }
};
struct X
{
bool b;
X (bool x) : b (x) {}
struct S_ { int M_; };
operator int S_::* () const { return b ? & S_::M_ : 0; }
};
int
main (int argc, char *argv[])
{
Bool b (X (true));
}
>How-To-Repeat:
g++ main.cc -o main
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: