public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: martin@xemacs.org
To: gcc-gnats@gcc.gnu.org
Subject: c++/9338: ICE in peculiar templated constructors
Date: Thu, 16 Jan 2003 09:36:00 -0000	[thread overview]
Message-ID: <20030116092931.17404.qmail@sources.redhat.com> (raw)


>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:


             reply	other threads:[~2003-01-16  9:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-16  9:36 martin [this message]
2003-01-16 15:12 bangerth
2003-04-07 10:56 Giovanni Bajo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030116092931.17404.qmail@sources.redhat.com \
    --to=martin@xemacs.org \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).