public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* 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 12:51 Type based aliasing Robert Dewar
@ 2002-10-05 13:33 ` Toon Moene
  0 siblings, 0 replies; 10+ messages in thread
From: Toon Moene @ 2002-10-05 13:33 UTC (permalink / raw)
  To: Robert Dewar; +Cc: nathan, gcc

Robert Dewar wrote:

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

The rule is that you can't `define' a dummy argument that's 
argument-associated with another dummy argument.

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

-- 
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
Join GNU Fortran 95: http://g95.sourceforge.net/ (under construction)

^ 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

* Re: Type based aliasing
  2002-10-05 14:21 Robert Dewar
@ 2002-10-05 15:00 ` Toon Moene
  0 siblings, 0 replies; 10+ messages in thread
From: Toon Moene @ 2002-10-05 15:00 UTC (permalink / raw)
  To: Robert Dewar; +Cc: gcc, nathan

Robert Dewar wrote:

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

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

-- 
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
Join GNU Fortran 95: http://g95.sourceforge.net/ (under construction)

^ 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 12:00 ` Toon Moene
@ 2002-10-05 12:45   ` Nathan Sidwell
  0 siblings, 0 replies; 10+ messages in thread
From: Nathan Sidwell @ 2002-10-05 12:45 UTC (permalink / raw)
  To: Toon Moene; +Cc: gcc

Toon Moene wrote:

>> (f77 has code like the above, where the condition may or may not be 
>> false.)
> 
> 
> 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.
yes.Sorry to be unclear, the f77 front end has such (C) code. I will
provide the obvious patch to inhibit the warning.

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-02 14:47 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
  2 siblings, 1 reply; 10+ messages in thread
From: Toon Moene @ 2002-10-05 12:00 UTC (permalink / raw)
  To: Nathan Sidwell; +Cc: gcc

Nathan Sidwell wrote:

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

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.

-- 
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
Join GNU Fortran 95: http://g95.sourceforge.net/ (under construction)

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

* Re: Type based aliasing
  2002-10-02 14:47 Nathan Sidwell
  2002-10-02 15:39 ` Michael Matz
@ 2002-10-02 16:17 ` Michael Matz
  2002-10-05 12:00 ` Toon Moene
  2 siblings, 0 replies; 10+ messages in thread
From: Michael Matz @ 2002-10-02 16:17 UTC (permalink / raw)
  To: Nathan Sidwell; +Cc: gcc

Hi,

On Wed, 2 Oct 2002, Nathan Sidwell wrote:

> 	void foo (int *ip, float *fp)
> 	{
> 		if (ip == fp)
> 			this_is_unreachable ()
> 	}

A followup to my last mail.  Think about this:

void bar ()
{
  int i;
  int *ip = &f;
  foo ( ip, (float *)ip);
}

Suppose, that in your foo() for the compare 'fp' is casted to 'int*'
(maybe because it has looser alignment).  Then it's required per
6.3.2.3 #7 to compare equal to the original pointer, which is ip.


Ciao,
Michael.

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

* Re: Type based aliasing
  2002-10-02 14:47 Nathan Sidwell
@ 2002-10-02 15:39 ` Michael Matz
  2002-10-02 16:17 ` Michael Matz
  2002-10-05 12:00 ` Toon Moene
  2 siblings, 0 replies; 10+ messages in thread
From: Michael Matz @ 2002-10-02 15:39 UTC (permalink / raw)
  To: Nathan Sidwell; +Cc: gcc

Hi,

On Wed, 2 Oct 2002, Nathan Sidwell wrote:

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

Why should it?  The accessed values are 'ip' and 'fp' itself and they are
accessed through their effective type.  So 6.5.7 is fullfilled, ergo the
accesses to 'ip' and 'fp' are defined.  The compare itself is Ok, as even
if everything breaks, one of the two pointer can be converted to the other
pointer type, which is only undefined, if alignment rules of that type are
not followed.


Ciao,
Michael.

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

* 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

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-05 12:51 Type based aliasing Robert Dewar
2002-10-05 13:33 ` Toon Moene
  -- strict thread matches above, loose matches on Subject: below --
2002-10-05 16:39 Robert Dewar
2002-10-05 14:21 Robert Dewar
2002-10-05 15:00 ` Toon Moene
2002-10-02 14:47 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

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