Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #22882

Re: Function casting - UB?

From James Kuyper <jameskuyper@verizon.net>
Newsgroups comp.lang.c
Subject Re: Function casting - UB?
Date 2012-06-27 14:45 -0400
Organization A noiseless patient Spider
Message-ID <4FEB54D7.2030106@verizon.net> (permalink)
References <0c176b1e-39f3-4e65-8a7b-eca16b8955c5@d24g2000yqh.googlegroups.com> <jsfhfs$m4n$2@dont-email.me>

Show all headers | View raw


On 06/27/2012 01:59 PM, Les Cargill wrote:
> nroberts wrote:
...
>> anyway?  What I mean is things like the fact that it's UB to assign to
>> one part of a union and read from another
> 
> I am not sure that that is undefined behavior. That's sort of what
> unions are *for*.

A footnote in the current version of the standard says that the result
of reading from a different member of a union than the one last written
is that the bit pattern stored in that memory is reinterpreted according
to the type of the member being read; it would therefore have defined
behavior, so long as that bit pattern is a valid one for that type.
Some have claimed that this conclusion can be derived from the normative
text of the standard, but I find the argument supporting that claim
weak. There's certainly no normative text that says so directly.
However, that is how unions were always intended to work, whether or not
the normative text of the standard has ever actually said so.

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Function casting - UB? nroberts <roberts.noah@gmail.com> - 2012-06-27 08:50 -0700
  Re: Function casting - UB? Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-06-27 12:49 -0400
    Re: Function casting - UB? Heikki Kallasjoki <fis+usenet@zem.fi> - 2012-06-27 17:54 +0000
      Re: Function casting - UB? "io_x" <a@b.c.invalid> - 2012-06-28 18:58 +0200
  Re: Function casting - UB? Tim Rentsch <txr@alumni.caltech.edu> - 2012-06-27 10:37 -0700
    Re: Function casting - UB? Johannes Bauer <dfnsonfsduifb@gmx.de> - 2012-06-28 09:23 +0200
      Re: Function casting - UB? Johannes Bauer <dfnsonfsduifb@gmx.de> - 2012-06-28 09:27 +0200
        Re: Function casting - UB? Jens Gustedt <jens.gustedt@loria.fr> - 2012-06-28 12:03 +0200
          Re: Function casting - UB? Tim Rentsch <txr@alumni.caltech.edu> - 2012-06-29 11:10 -0700
      Re: Function casting - UB? Tim Rentsch <txr@alumni.caltech.edu> - 2012-06-29 11:03 -0700
  Re: Function casting - UB? Les Cargill <lcargill99@comcast.com> - 2012-06-27 12:58 -0500
  Re: Function casting - UB? Les Cargill <lcargill99@comcast.com> - 2012-06-27 12:59 -0500
    Re: Function casting - UB? James Kuyper <jameskuyper@verizon.net> - 2012-06-27 14:45 -0400
      Re: Function casting - UB? "christian.bau" <christian.bau@cbau.wanadoo.co.uk> - 2012-06-27 14:55 -0700
        Re: Function casting - UB? Tim Rentsch <txr@alumni.caltech.edu> - 2012-06-27 17:44 -0700
          Re: Function casting - UB? Joshua Maurice <joshuamaurice@gmail.com> - 2012-07-07 16:46 -0700
            Re: Function casting - UB? Barry Schwarz <schwarzb@dqel.com> - 2012-07-08 09:19 -0700
              Re: Function casting - UB? Tim Rentsch <txr@alumni.caltech.edu> - 2012-07-08 11:13 -0700
                Re: Function casting - UB? Barry Schwarz <schwarzb@dqel.com> - 2012-07-08 15:24 -0700
                Re: Function casting - UB? Joshua Maurice <joshuamaurice@gmail.com> - 2012-07-08 18:12 -0700
                Re: Function casting - UB? Tim Rentsch <txr@alumni.caltech.edu> - 2012-07-10 10:40 -0700
            Re: Function casting - UB? Tim Rentsch <txr@alumni.caltech.edu> - 2012-07-08 11:06 -0700

csiph-web