Subject: c++ warning...help?
To: None <tech-toolchain@netbsd.org>
From: Andrew Brown <atatat@atatdot.net>
List: tech-toolchain
Date: 06/21/2001 20:23:52
i've got this library[1] (and accompanying demos/tests) that i'm
trying to compile (on i386, and then alpha, and maybe sparc although
that might be rough) and compiling gives me a lot of warnings like
this:

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

i guess my c++ isn't as good as i'd like, since this is just confusing
to me, despite my having read through the c++ arm and "the c++
programming language" for hints.

the offending function looks like this:

64:	inline udigit
65:	udigit_add (udigit & sum, udigit a, udigit b, udigit carry)
66:	        //RV * 2^base + sum = a + b + carry
67:	{
68:		udigit new_carry;
69:
70:
71:		add_ssaaaa(new_carry, sum, 0, a, 0, b);
72:		if (carry == 0) {
73:			return new_carry;
74:		}
75:		add_ssaaaa(new_carry, sum, new_carry, sum, 0, carry);
76:		return new_carry;
77:	}

and the function add_ssaaaa() comes from the longlong.h header file
"stolen" from the gmp build tree which, on i386, is a macro that does
this:

	#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
	  __asm__ ("addl %5,%1\n\tadcl %3,%0"                           \
	           : "=r" ((USItype)(sh)), "=&r" ((USItype)(sl))        \
	           : "%0" ((USItype)(ah)), "g" ((USItype)(bh)),         \
	             "%1" ((USItype)(al)), "g" ((USItype)(bl)))

which the preprocessor turns into this (for line 71):

	__asm__ ("addl %5,%1\n\tadcl %3,%0" :
	"=r" ((USItype)( new_carry )), "=&r" ((USItype)( sum )) :
	"%0" ((USItype)( 0 )), "g" ((USItype)( 0 )),
        "%1" ((USItype)( a )), "g" ((USItype)( b ))) ;

(i've added line breaks and condensed the spacing for readability).

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

[1] it's called LiDIA, and it's a "c++ library for computational
number theory" which you can read about and download at
http://www.informatik.tu-darmstadt.de/TI/LiDIA/ if you want to.  it
requires gmp and copying a file (longlong.h) from the gmp compile tree
into the LiDIA tree and constant hand-holding to get it to compile,
but it will.  on i386, at least, so far.

-- 
|-----< "CODE WARRIOR" >-----|
codewarrior@daemon.org             * "ah!  i see you have the internet
twofsonet@graffiti.com (Andrew Brown)                that goes *ping*!"
andrew@crossbar.com       * "information is power -- share the wealth."