public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Type based aliasing
@ 2002-10-02 14:47 Nathan Sidwell
  2002-10-02 15:39 ` Michael Matz
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Nathan Sidwell @ 2002-10-02 14:47 UTC (permalink / raw)
  To: gcc

Hi,
Do C's type based aliasing rules mean the following?
	void foo (int *ip, float *fp)
	{
		if (ip == fp)
			this_is_unreachable ()
	}

I vaguely remember some discussion about this, but can't remember the
conclusion. Presumably IP & FP could point to members of the same union.

(f77 has code like the above, where the condition may or may not be false.)

nathan
-- 
Dr Nathan Sidwell   ::   http://www.codesourcery.com   ::   CodeSourcery LLC
          'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org


^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: Type based aliasing
@ 2002-10-05 12:51 Robert Dewar
  2002-10-05 13:33 ` Toon Moene
  0 siblings, 1 reply; 10+ messages in thread
From: Robert Dewar @ 2002-10-05 12:51 UTC (permalink / raw)
  To: nathan, toon; +Cc: gcc

<<Fortran rules don't allow arguments (which are references in g77) to
overlap at all, so in this case, g77 would just assume (without
checking) that *ip and *fp wouldn't overlap.
>>

Is that really true? I thought the rule was that if there is any aliasing
then assignment by any alias path is forbidden (this certainly was the
original rule in Fortran, it might have changed, but that would surprise me).

^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: Type based aliasing
@ 2002-10-05 14:21 Robert Dewar
  2002-10-05 15:00 ` Toon Moene
  0 siblings, 1 reply; 10+ messages in thread
From: Robert Dewar @ 2002-10-05 14:21 UTC (permalink / raw)
  To: dewar, toon; +Cc: gcc, nathan

<<`Define' in Fortran-speak is to `have a value assigned to it and all of
the entities that are associated with it'.

Assignment is one way to cause problems here, but not the only one.
>>

OK, sure, I was using assignment loosely, but the statement that "Fortran
rules don't allow arguments to overlap at all" is definitely misleading,
since it is just fine for arguments to overlap providing that no definitions
occur in an aliased situation.

^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: Type based aliasing
@ 2002-10-05 16:39 Robert Dewar
  0 siblings, 0 replies; 10+ messages in thread
From: Robert Dewar @ 2002-10-05 16:39 UTC (permalink / raw)
  To: dewar, toon; +Cc: gcc, nathan

>>Yep, this is definitely true and might by worth stressing.

I always thought that this was a clever way of dealing with aliasing. Very
precisely defined, and you could in fact add run time checks for this if you
wanted.

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

end of thread, other threads:[~2002-10-05 20:56 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-02 14:47 Type based aliasing Nathan Sidwell
2002-10-02 15:39 ` Michael Matz
2002-10-02 16:17 ` Michael Matz
2002-10-05 12:00 ` Toon Moene
2002-10-05 12:45   ` Nathan Sidwell
2002-10-05 12:51 Robert Dewar
2002-10-05 13:33 ` Toon Moene
2002-10-05 14:21 Robert Dewar
2002-10-05 15:00 ` Toon Moene
2002-10-05 16:39 Robert Dewar

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