Subject: Re: c++ warning...help?
To: Andrew Brown <atatat@atatdot.net>
From: gabriel rosenkoetter <gr@eclipsed.net>
List: tech-toolchain
Date: 06/22/2001 11:11:23
On Thu, Jun 21, 2001 at 08:23:52PM -0400, Andrew Brown wrote:
> 	../include/LiDIA/kernel/udigit_interface.h:71: warning: \
> 	ANSI C++ forbids cast to non-reference type used as lvalue
> 	../include/LiDIA/kernel/udigit_interface.h:71: warning: \
> 	ANSI C++ forbids cast to non-reference type used as lvalue
> 	../include/LiDIA/kernel/udigit_interface.h:75: warning: \
> 	ANSI C++ forbids cast to non-reference type used as lvalue
> 	../include/LiDIA/kernel/udigit_interface.h:75: warning: \
> 	ANSI C++ forbids cast to non-reference type used as lvalue

Wow. g++ is totally confused. There's no kind of (C or C++) lvalue
on that line. It really oughtn't even be doing checks for casting
and such in asm code.

> which the preprocessor turns into this (for line 71):
> 
> 	__asm__ ("addl %5,%1\n\tadcl %3,%0" :
> 	"=r" ((USItype)( new_carry )), "=&r" ((USItype)( sum )) :
				 ^^^^^^^^^^^^^a^^^^^^^^^^  ^b^

The parser things (a) is a cast to the left of (b), which it
believes in an assignment operator, making (a) an illegal cast in an
lvalue.

Of course it's no such thing, since that particular = has nothing to
do with assignment operator or, really, a C operator of any kind
(assignment is the only time this kind of lvalue checking really
matters).

> what i *don't* understand is what it's actually complaining about.
> anyone?  please?

Well, does the code compile? Run? If so, ignore that warning,
because g++ is off its rocker to yield it. (Oh, um, I guess you'll
have trouble if your Makefiles treat warnings as errors... but I
can't think of a good way to block against that off the top of my
head. Of course, I don't exactly toss asm() around very frequently,
so maybe someone else will have a better idea.)

Unless I'm totally missing something...

-- 
       ~ g r @ eclipsed.net