public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: Could egcs warn at (int*)(int)(x)?
@ 1997-12-15 11:59 Tobias Polzin
  0 siblings, 0 replies; 3+ messages in thread
From: Tobias Polzin @ 1997-12-15 11:59 UTC (permalink / raw)
  To: egcs

Sorry, I forgot to mention that it was a C++ program.
Obviously gcc warns about such problems, but g++ does not.

  int* foo=(int*)((int)bar + delta);

Tobias Polzin

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Could egcs warn at (int*)(int)(x)?
  1997-12-15  9:34 Tobias Polzin
@ 1997-12-15 10:37 ` Richard Henderson
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Henderson @ 1997-12-15 10:37 UTC (permalink / raw)
  To: egcs

On Mon, Dec 15, 1997 at 06:34:46PM +0100, Tobias Polzin wrote:
> Is there any possibility to get warnings for things like:
>    int* foo=(int*)((int)bar + delta);

We do already, and have done so for quite some time.  No extra
warning flags are necessary, c.f. "gcc -c z.c":

void f(int *bar, int delta)
{
  int* foo=(int*)((int)bar + delta);
}

z.c: In function `f':
z.c:3: warning: cast from pointer to integer of different size
z.c:3: warning: cast to pointer from integer of different size

> Or even for
>    int  delta= long(newaddress)-long(oldaddress).

Maybe, but I always found these loss of precision warnings to
be more annoying than helpful.  It happens way too often in
normal code.

Almost all 64-bit errors are caught by the ptr/int warnings.


r~

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Could egcs warn at (int*)(int)(x)?
@ 1997-12-15  9:34 Tobias Polzin
  1997-12-15 10:37 ` Richard Henderson
  0 siblings, 1 reply; 3+ messages in thread
From: Tobias Polzin @ 1997-12-15  9:34 UTC (permalink / raw)
  To: egcs

I had problems with porting a software package to a 64 bit architecture.
After exhausting debugging-sessions I found that the problem were "pointer->
int->pointer"-casts which loose the upper 32 bit of the address. 
The usual warnings (-wAll -Wconversion -Wpointer-arith) do not detect
this porblems.

Is there any possibility to get warnings for things like:
   int* foo=(int*)((int)bar + delta);
Or even for
   int  delta= long(newaddress)-long(oldaddress).

Tobias "2b" Polzin

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1997-12-15 11:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-12-15 11:59 Could egcs warn at (int*)(int)(x)? Tobias Polzin
  -- strict thread matches above, loose matches on Subject: below --
1997-12-15  9:34 Tobias Polzin
1997-12-15 10:37 ` Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).