Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | James Kuyper <jameskuyper@verizon.net> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Do not cast pointers to functions to pointers to primitive types |
| Date | 2012-09-04 17:10 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <50466E3A.2000303@verizon.net> (permalink) |
| References | <fce4988c-58d7-4847-84fe-edb1ed3b722c@googlegroups.com> <lnharevbgq.fsf@nuthaus.mib.org> <k23ni1$hmn$1@speranza.aioe.org> <lntxvettoe.fsf@nuthaus.mib.org> <k25o72$imk$1@speranza.aioe.org> |
On 09/04/2012 04:27 PM, Alan Curry wrote: > In article <lntxvettoe.fsf@nuthaus.mib.org>, > Keith Thompson <kst-u@mib.org> wrote: >> >> So you don't want to distinguish between casts whose behavior >> is well defined, those whose behavior is implementation-defined, >> and those whose behavior is completely undefined? >> >> I can understand that opinion, but it hardly seems reasonable to >> call those who disagrees with it idiots. >> >> Casts are commonly interpreted to mean "Shut up, compiler, I know >> what I'm doing"-- but the standard doesn't say or imply that. >> >> How do you feel about casts applied to struct types, which are a >> constraint violation? > > Those are errors, not warnings. You can't cast away an error. > > Failure to distinguish errors and warnings is a problem that only The > Standard has. In the real world everybody knows they're different. The standard cannot distinguish between error messages and warning messages, because whether or not something constitutes an error is highly dependent on factors outside the scope of the standard. The code in question has undefined behavior, the worst thing that the standard can say about any code construct. However, the X/Open standard does define the behavior (a fact which is outside the scope of the C standard). A programmer who decides to write code which relies upon that definition, believing that it will only ever need to be run on systems that conform to the X/Open standard (something else that is also outside the scope of the C standard) is NOT making an error (unless that belief is incorrect). The standard leaves the distinction between errors and warnings up to the implementations. Were you rewriting the C standard to remove that freedom, how would you make that distinction in such a way as to apply to cases like this? It seems to me that a mind-reading compiler with the capacity to make better judgements than the developer about the reasonability of such beliefs is needed, in order to make that distinction.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Do not cast pointers to functions to pointers to primitive types ajaybgr <ajay.bgr@gmail.com> - 2012-09-03 01:50 -0700
Re: Do not cast pointers to functions to pointers to primitive types Ian Collins <ian-news@hotmail.com> - 2012-09-03 20:59 +1200
Re: Do not cast pointers to functions to pointers to primitive types Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-09-03 02:13 -0700
Re: Do not cast pointers to functions to pointers to primitive types Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-09-03 11:24 +0100
Re: Do not cast pointers to functions to pointers to primitive types James Kuyper <jameskuyper@verizon.net> - 2012-09-03 08:31 -0400
Re: Do not cast pointers to functions to pointers to primitive types Keith Thompson <kst-u@mib.org> - 2012-09-03 13:21 -0700
Re: Do not cast pointers to functions to pointers to primitive types James Kuyper <jameskuyper@verizon.net> - 2012-09-03 16:57 -0400
Re: Do not cast pointers to functions to pointers to primitive types Keith Thompson <kst-u@mib.org> - 2012-09-03 14:48 -0700
Re: Do not cast pointers to functions to pointers to primitive types pacman@kosh.dhis.org (Alan Curry) - 2012-09-03 21:57 +0000
Re: Do not cast pointers to functions to pointers to primitive types Keith Thompson <kst-u@mib.org> - 2012-09-03 18:11 -0700
Re: Do not cast pointers to functions to pointers to primitive types pacman@kosh.dhis.org (Alan Curry) - 2012-09-04 02:03 +0000
Re: Do not cast pointers to functions to pointers to primitive types Keith Thompson <kst-u@mib.org> - 2012-09-03 19:20 -0700
Re: Do not cast pointers to functions to pointers to primitive types pacman@kosh.dhis.org (Alan Curry) - 2012-09-04 20:27 +0000
Re: Do not cast pointers to functions to pointers to primitive types James Kuyper <jameskuyper@verizon.net> - 2012-09-04 17:10 -0400
Re: Do not cast pointers to functions to pointers to primitive types Barry Schwarz <schwarzb@dqel.com> - 2012-09-04 14:14 -0700
Re: Do not cast pointers to functions to pointers to primitive types pete <pfiland@mindspring.com> - 2012-09-03 22:51 -0400
Re: Do not cast pointers to functions to pointers to primitive types Vincenzo Mercuri <vincenzo.mercuri@yahoo.it> - 2012-09-04 00:02 +0200
Re: Do not cast pointers to functions to pointers to primitive types Keith Thompson <kst-u@mib.org> - 2012-09-03 18:19 -0700
Re: Do not cast pointers to functions to pointers to primitive types Kaz Kylheku <kaz@kylheku.com> - 2012-09-04 01:18 +0000
Re: Do not cast pointers to functions to pointers to primitive types "Scott Fluhrer" <sfluhrer@ix.netcom.com> - 2012-09-04 11:59 -0400
Re: Do not cast pointers to functions to pointers to primitive types Philip Lantz <prl@canterey.us> - 2012-09-06 21:34 -0700
csiph-web