Logo Search packages:      
Sourcecode: gcc-2.96 version File versions


From: Boris Gjenero <bgjenero@sympatico.ca>
Sender: bgjenero@cs.tu-berlin.de
To: submit@bugs.debian.org
Subject: Bug#79225: g++ handles &(void *)foo bizzarely
Date: Sat, 09 Dec 2000 22:10:48 -0500

Package: g++
Version: 2.95.2-13

I used &(void *)foo to get a void ** which points to foo where foo is a
pointer of a different type.  This worked when I compiled without
optimization, but it silently breaks when used with optimization.  It
also causes errors with other versions of g++. 

For example, on a system where "gcc -v" says:
 Reading specs from
 gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
That constuct causes the error: "non-lvalue in unary `&'"

So, the most probable problem is that &(void *)foo is invalid and the
version of g++ that I'm using fails to generate an error.

I have used &(void *)foo in two files and with -02 both broke.  So it
may even break in all cases, but I'll nevertheless include both
functions where this problem occured.  Note that in them &(void *)foo
has already been changed to (void **)(&foo), and they now work okay even
with -O2.

--function 1--

void FileSpecList::RemoveAll() {
        CEgFileSpec* spec;
        while ( mSpecs.FetchLast( (void **)(&spec) ) ) {
                delete spec;
--end of function 1--

--function 2--
float* ExpressionDict::LookupVar( const UtilStr& inName ) {
        float* addr;
        if ( mVarDict.Get( &inName, (void **)(&addr) ) )
                return addr;
                return NULL;
--end of function 2--

Generated by  Doxygen 1.6.0   Back to index