This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

c++/9824: weird non-lvalue error with ?: operator


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]