public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/9824: weird non-lvalue error with ?: operator
@ 2003-02-24  8:26 snyder
  0 siblings, 0 replies; 2+ messages in thread
From: snyder @ 2003-02-24  8:26 UTC (permalink / raw)
  To: gcc-gnats


>Number:         9824
>Category:       c++
>Synopsis:       weird non-lvalue error with ?: operator
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Mon Feb 24 08:26:02 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     scott snyder
>Release:        3.4 20030224 (experimental)
>Organization:
>Environment:
System: Linux karma 2.4.19-emp_2419p5a829i #1 Tue Sep 3 17:42:17 EST 2002 i686 unknown
Architecture: i686

	
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc/configure --prefix=/usr/local/gcc --enable-threads=posix --enable-long-long : (reconfigured) 
>Description:

g++ gives errors when compiling the source below:

[sss@karma gcc]$ g++ -c x.cc
x.cc: In function `void xxx(int)':
x.cc:17: error: non-lvalue in unary `&'
x.cc:17: error: non-lvalue in unary `&'
x.cc:17: error: non-lvalue in unary `&'
x.cc:17: error: non-lvalue in unary `&'
x.cc:17: error: non-lvalue in unary `&'
$

As far as i can tell, the code is valid --- in any case, the error
is not very helpful, since the code nowhere uses the unary `&' operator
that the message is complaining about.

Rewriting the ternary operator as an if-else makes the error go away,
as does removing the ACE_Time_Value constructor declarations (all of them).

>How-To-Repeat:

---------------------------------------
struct timespec;
struct timeval;

struct ACE_Time_Value
{
  static const ACE_Time_Value max_time;
  ACE_Time_Value (long sec, long usec = 0);
  ACE_Time_Value (const timeval &t);
  ACE_Time_Value (const timespec &t);
  operator timespec () const;
};

static ACE_Time_Value foo (void);

void xxx (int x)
{
  x ? foo () : ACE_Time_Value::max_time;
}
---------------------------------------

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: c++/9824: weird non-lvalue error with ?: operator
@ 2003-02-24  9:56 steven
  0 siblings, 0 replies; 2+ messages in thread
From: steven @ 2003-02-24  9:56 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, snyder

Synopsis: weird non-lvalue error with ?: operator

State-Changed-From-To: open->closed
State-Changed-By: steven
State-Changed-When: Mon Feb 24 09:56:08 2003
State-Changed-Why:
    Duplicate of 9440

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9824


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-02-24  9:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-24  8:26 c++/9824: weird non-lvalue error with ?: operator snyder
2003-02-24  9:56 steven

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