delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/05/12/11:37:08

Date: Mon, 12 May 1997 11:33:01 -0400 (EDT)
From: "Art S. Kagel" <kagel AT ns1 DOT bloomberg DOT com>
To: "Salvador Eduardo Tropea (SET)" <salvador AT inti DOT edu DOT ar>
Cc: djgpp AT delorie DOT com
Subject: Re: C++ front end bug
In-Reply-To: <m0wPoem-000S1mC@natacha.inti.edu.ar>
Message-Id: <Pine.D-G.3.91.970512113147.24572A-100000@dg1>
Mime-Version: 1.0

On Fri, 9 May 1997, Salvador Eduardo Tropea (SET) wrote:

> Hi everybody:
> 
>   Here SET again with bad news. I'm comunicating bugs of GCC to the list
> because it can affect to somebody and I know how hard is to find a bug in
> a program when the fault is in the compiler.
>   "Daniel W. Moore" <dwmoore AT clark DOT net> reported a bug to the FSF in the C++
> front end. Looks like a bug but perhaps is something related to C++.
>   The following code outputs different results in C and C++. GCC just says
> that (void *)aa isn't equal to (void*)&aa, but if we ask for the value of
> each expression it return the same number.
>   So is that a bug or is something related to C++? From my point of view the
> cast to (void *) must kill any difference and hence that's a bug.
> 
> #include <stdio.h>
> 
> int aa[3]={7,8,9};
> 
> main()
> {
>   int i;
> 
>   /* the following statements  should print the same value twice */
>   printf("(void *)aa is %X and (void*)&aa is %X so they are %s equal!?!\n",
>   (void *)aa,(void*)&aa,((void*) aa != (void*) &aa) ? "not" : "");
> 
>   i = (((void*) aa != (void*) &aa) ? 0 : sizeof(aa));
>   printf(" %d\n", i);
> 
>   i = (((void*) aa == (void*) &aa) ? sizeof(aa) : 0);
>   printf(" %d\n", i);
> 
>   return 0;
> }
> ------------------------------------ 0 --------------------------------
> Visit my home page: http://www.geocities.com/SiliconValley/Vista/6552/
> Salvador Eduardo Tropea (SET). (Electronics Engineer)
> Address: Curapaligue 2124, Caseros, 3 de Febrero
> Buenos Aires, (1678), ARGENTINA
> TE: +(541) 759 0013
> 

I have verified that this is a G++ 'problem'.  It shows the same results 
on DG/UX gcc/g++ as SET describes.  Weird!

Art S. Kagel, kagel AT bloomberg DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019