public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: type based aliasing again - meaning of "undefined"
@ 1999-09-15 14:07 Ross Morgan-Linial
  1999-09-15 14:37 ` craig
                   ` (2 more replies)
  0 siblings, 3 replies; 46+ messages in thread
From: Ross Morgan-Linial @ 1999-09-15 14:07 UTC (permalink / raw)
  To: gcc

I've been watchin this discussion on the archives, and I'm a bit confused
about the meaning of "undefined" in the C9x standard, as you're using it.
The standard defines it as

       behavior, upon use of a  nonportable  or  erroneous  program
       construct,  of  erroneous data, or of indeterminately valued
       objects, for which this International  Standard  imposes  no
       requirement.

It seems to me that that says that a program that does something undefined
isn't necessarily wrong, just nonportable. Since previous versions of GCC
apparently behaved consistently when type aliasing requirements were
violated, why are programs that violate them considered erroneous? Or am I
misreading the standard?

    Ross

^ permalink raw reply	[flat|nested] 46+ messages in thread
* Re: type based aliasing again - meaning of "undefined"
@ 1999-09-15 19:07 Mike Stump
  1999-09-30 18:02 ` Mike Stump
  0 siblings, 1 reply; 46+ messages in thread
From: Mike Stump @ 1999-09-15 19:07 UTC (permalink / raw)
  To: mark; +Cc: craig

> Date: Wed, 15 Sep 1999 19:52:06 -0400
> From: Michael Meissner <meissner@cygnus.com>

> Also note the rules for ANSI C are different from ANSI C++ in terms
> of const.  For example, I recall the following:

> 	int i;
> 	*(int *)(const int *)&i = 1;

> is legit under ISO C.  IIRC, this is explicitly mentioned in one of
> the TC's (I was still a member of the committee when TC.1 came out).

C++ and C are about the same, and once C puts in multi-level const
handling, they will be the same.  You can do the above in C++ as well,
this isn't a difference between the languages.

^ permalink raw reply	[flat|nested] 46+ messages in thread
* Re: type based aliasing again - meaning of "undefined"
@ 1999-09-15 23:15 N8TM
  1999-09-30 18:02 ` N8TM
  0 siblings, 1 reply; 46+ messages in thread
From: N8TM @ 1999-09-15 23:15 UTC (permalink / raw)
  To: rmorgan

In a message dated 9/15/99 4:08:42 PM EST, rmorgan@jetcity.com writes:

> Since previous versions of GCC
>  apparently behaved consistently when type aliasing requirements were
>  violated, why are programs that violate them considered erroneous? 
Because they depend on the compiler not performing useful optimizations which 
the standard specifically encourages.

Tim

^ permalink raw reply	[flat|nested] 46+ messages in thread
* Re: type based aliasing again - meaning of "undefined"
@ 1999-09-16  8:24 David_Abrahams
  1999-09-30 18:02 ` David_Abrahams
  0 siblings, 1 reply; 46+ messages in thread
From: David_Abrahams @ 1999-09-16  8:24 UTC (permalink / raw)
  To: gcc

*quick delurkification*

It seems to me that an issue that ought to be of concern, but nobody is
      discussing is this: the compiler will at best be able to warn of a subset
      of aliasing violations.

Mark Mitchell <mark@codesourcery.com> wrote:
>If you compiler is instead an interpreter, it can do run-time checks,
>and then issue errors, ala Java.  The standard is trying to encourage
>these kinds of alternatives.

This is clearly the only way to find all aliasing violations, and that's
_assuming_ interpreted code could be sufficiently exercised.

Isn't anyone worried that users will expect (particularly if they see some
warnings) that if they clear up the warnings their code will work? I don't have
a position on the issue, but I worry about checks which seem to promise more
than they actually do, especially when the target audience includes "naive
users".

Handling this sort of issue in C++ is easy enough, in some sense: you can tell
people to avoid casts (and they usually are avoidable), then go and inspect the
dangerous areas by finding the few casts that are left. Not so easy with
existing bodies of 'C' code :(

-Dave


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

end of thread, other threads:[~1999-09-30 18:02 UTC | newest]

Thread overview: 46+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-09-15 14:07 type based aliasing again - meaning of "undefined" Ross Morgan-Linial
1999-09-15 14:37 ` craig
1999-09-15 14:58   ` Ross Morgan-Linial
1999-09-15 15:22     ` craig
1999-09-30 18:02       ` craig
1999-09-30 18:02     ` Ross Morgan-Linial
1999-09-15 15:01   ` Mark Mitchell
1999-09-15 15:11     ` Ross Morgan-Linial
1999-09-15 15:24       ` craig
1999-09-15 15:58         ` Ross Morgan-Linial
1999-09-15 16:42           ` Mark Mitchell
1999-09-30 18:02             ` Mark Mitchell
1999-09-16 14:28           ` craig
1999-09-30 18:02             ` craig
1999-09-30 18:02           ` Ross Morgan-Linial
1999-09-30 18:02         ` craig
1999-09-15 15:45       ` Mark Mitchell
1999-09-15 16:17         ` Ross Morgan-Linial
1999-09-15 16:49           ` Mark Mitchell
1999-09-30 18:02             ` Mark Mitchell
1999-09-30 18:02           ` Ross Morgan-Linial
1999-09-15 16:52         ` Michael Meissner
1999-09-15 17:16           ` Mark Mitchell
1999-09-30 18:02             ` Mark Mitchell
1999-09-15 17:32           ` Ross Smith
1999-09-30 18:02             ` Ross Smith
1999-09-30 18:02           ` Michael Meissner
1999-09-16  1:32         ` Marc Espie
1999-09-16  2:15           ` Alexandre Oliva
1999-09-30 18:02             ` Alexandre Oliva
1999-09-16  8:09           ` Mark Mitchell
1999-09-30 18:02             ` Mark Mitchell
1999-09-30 18:02           ` Marc Espie
1999-09-30 18:02         ` Mark Mitchell
1999-09-30 18:02       ` Ross Morgan-Linial
1999-09-30 18:02     ` Mark Mitchell
1999-09-30 18:02   ` craig
1999-09-15 15:20 ` David Edelsohn
1999-09-30 18:02   ` David Edelsohn
1999-09-30 18:02 ` Ross Morgan-Linial
1999-09-15 19:07 Mike Stump
1999-09-30 18:02 ` Mike Stump
1999-09-15 23:15 N8TM
1999-09-30 18:02 ` N8TM
1999-09-16  8:24 David_Abrahams
1999-09-30 18:02 ` David_Abrahams

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