public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/10245: regression in 3.3, C++ ternary operator confuses type lookup
@ 2003-03-27 17:16 harri.pasanen
  0 siblings, 0 replies; only message in thread
From: harri.pasanen @ 2003-03-27 17:16 UTC (permalink / raw)
  To: gcc-gnats; +Cc: tot, jean-paul_marinier


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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-03-27 17:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-27 17:16 c++/10245: regression in 3.3, C++ ternary operator confuses type lookup harri.pasanen

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).