public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: harri.pasanen@trema.com
To: gcc-gnats@gcc.gnu.org
Cc: tot@trema.com, jean-paul_marinier@hp.com
Subject: c++/10245: regression in 3.3, C++ ternary operator confuses type lookup
Date: Thu, 27 Mar 2003 17:16:00 -0000	[thread overview]
Message-ID: <20030327165729.511.qmail@sources.redhat.com> (raw)


>Number:         10245
>Category:       c++
>Synopsis:       regression in 3.3, C++ ternary operator confuses type lookup
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Mar 27 17:06:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     harri.pasanen@trema.com
>Release:        unknown-1.0
>Organization:
>Environment:
gcc version 3.3 20030326 (prerelease)
>Description:
// Ternary operator throws the type resolution of balance.

namespace Type
{
  struct Date {
    int foo;
  };
};

typedef int fc_Date;

struct from_date
{
  const fc_Date &_date;
  from_date (const fc_Date &date) throw ()
    : _date (date) {}

  // Operator to convert to type date.
  operator Type::Date () const throw ()
    { Type::Date tem;
      return tem; }
private:
  // Not implemented.
  from_date ();
  from_date (const from_date &);
};

fc_Date aday() { return 1; }

#ifdef BUG
void foo()
{
  fc_Date adate, bdate;
  Type::Date d = (aday () != 0 ? from_date (adate) : from_date (bdate));
}
#else
void foo()
{
  fc_Date adate, bdate;
  Type::Date d;
  if (aday () != 0)
    d = from_date (adate);
  else
    d = from_date (bdate);
}
#endif
>How-To-Repeat:
Save the code above to file gccbug.cxx
g++ -c -DBUG gccbug.cxx
will fail to compile it g++ is 3.3 snapshot  20030326, with the message:
gccbug.cxx: In function `void foo()':
gccbug.cxx:23: error: `from_date::from_date(const from_date&)' is private
gccbug.cxx:32: error: within this context
gccbug.cxx:23: error: `from_date::from_date(const from_date&)' is private
gccbug.cxx:32: error: within this context

The -DBUG can be used to illustrate the bug in 3.3 snapshot. 
 g++ 2.96, 3.0.4 and 3.2.2 all compile the example both  with and without -DBUG.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


                 reply	other threads:[~2003-03-27 17:06 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20030327165729.511.qmail@sources.redhat.com \
    --to=harri.pasanen@trema.com \
    --cc=gcc-gnats@gcc.gnu.org \
    --cc=jean-paul_marinier@hp.com \
    --cc=tot@trema.com \
    /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).