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


Groups > comp.lang.c > #30470

Re: [union] Pointers to inherited structs are valid ?

From Shao Miller <sha0.miller@gmail.com>
Newsgroups comp.lang.c
Subject Re: [union] Pointers to inherited structs are valid ?
Date 2013-01-21 14:07 -0500
Organization A noiseless patient Spider
Message-ID <kdk3mf$td7$1@dont-email.me> (permalink)
References (17 earlier) <0.0b1231aec01398fe5573.20130120235839GMT.87libn76fk.fsf@bsb.me.uk> <kdi97a$32l$1@dont-email.me> <0.3967aeb7bf6a1530832e.20130121025322GMT.87fw1v6ycd.fsf@bsb.me.uk> <kdiibb$adj$1@dont-email.me> <0.daa800410407a948d170.20130121163138GMT.874nia7b11.fsf@bsb.me.uk>

Show all headers | View raw


On 1/21/2013 11:31, Ben Bacarisse wrote:
> Shao Miller <sha0.miller@gmail.com> writes:
>>
>> Not explicitly, no.  I thought it would be obvious that it was the
>> context of a Windows debugger notifying the programmer, since Geoff
>> had just discussed that.
>
> I don't recall Geoff saying that anything was unexpected.  That's your
> phrase that you admit you have not defined.  I can't fathom what you
> think is unexpected behaviour or what point that would made.  Should I
> be able to work it out?
>

No, I'm explaining the nature of my mistake.  "I thought it would be 
obvious." <- Wrong.

> Geoff's post looks simple and correct: the standard permits trap
> representations that produce undefined behaviour so an implementation is
> permitted to use special values to trigger interesting effects (either
> in a debugger or else where).
>

I agree that his post does look that way and that C does allow for that. 
  There's a subtle bit here, though: If we're discussing a program, once 
that program invokes undefined behaviour, anything goes.  However, if 
I'm not mistaken, with Windows NT, if you have a pointer value which 
does not point to an object, the program will continue to operate as per 
the C semantics until such a time (if ever) as that pointer might be 
used for indirect access.

So it is imprecise to say that such a value has a trap representation, 
because the behaviour is still well-defined.  Otherwise, the last 
sentence of N1570's 6.5.3.2p4 is redundant:

   "If an invalid value has been assigned to the pointer, the behavior 
of the unary * operator is undefined.102)"

But anyway, a pointer value pointing to no object can still be "trapped" 
by Windows during indirection and can still provide useful information 
to a Windows debugger.  It just does not precisely match C's trap 
representation, for behavioural differences.

>
> No I read in context and try to respond in context as well.  I don't
> think I missed the context.
>

Well then that's my mistake.

>> In that quote, I thought it was obvious that this
>> was in the context of using a Microsoft debugger, where the behaviour
>> would agree with the semantics of an "unspecified value"; not warning
>> the programmer during a read of the value (which it _could_).
>
> It could be an unspecified value (you are explicitly using C terms here)
> if it is a valid pointer value.  It may well be.  Is it?   It may equally
> well not be.  It could be either a trap representation or an unspecified
> value but you seem to suggest that it is one not the other.  You seem to
> suggest that one possibility is more likely than the other for reasons
> that are spurious.  The best evidence that it might not be a trap
> representation is that it's a valid pointer, but you give no evidence for
> that -- quite the contrary in fact.
>

I'd say that it is not a trap representation.

Take Windows NT's 'IRP' structure.  It has a sub-member called 
'Tail.Overlay.DriverContext', which is an array of 4 'void *'.  This is 
one of _very_few_ places where a driver can associate information with 
an IRP, and is extremely valuable for that reason.

The implementation defines the results of casting an appropriately-sized 
integer value to a 'void *', so such an integer can be "passed" via this 
mechanism.  We _certainly_ would not wish to believe that this results 
in undefined behaviour, so we certainly would not wish to believe that 
such a result is a trap representation.

>>
>> B: "Here are Microsoft's documented [non-C] trap values..."
>
> If this was Geoff, he correctly called then "trap representation"
> (rather than values) and he referred to "they" meaning the C committee.
> He was talking at C trap representations not "[non-C] trap values".
>

This was in regards to the lower part of his post where he specifically 
says "Microsoft documents their compiler trap values".

>> Me: "Nice summary!  Say, isn't there another one, 0x0000000C, as a
>> [non-C] trap for [non-C] null pointers?  I don't remember..."
>>
>> C: "Oh no, that wouldn't be a [C] null pointer."
>>
>> Me: "Yes, well I was talking about B's [non-C] trap values.  I see a
>> Microsoft debugger catch these things and call them [non-C] null
>> pointers."
>
> I think you missed Geoff's point.
>

I doubt it.

-- 
- Shao Miller
--
"Thank you for the kind words; those are the kind of words I like to hear.

Cheerily,"  -- Richard Harter

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


Thread

[union] Pointers to inherited structs are valid ? Maciej Labanowicz <m.labanowicz@gmail.com> - 2013-01-01 03:45 -0800
  Re: [union] Pointers to inherited structs are valid ? Barry Schwarz <schwarzb@dqel.com> - 2013-01-01 17:59 -0800
    Re: [union] Pointers to inherited structs are valid ? Tim Rentsch <txr@alumni.caltech.edu> - 2013-01-02 10:18 -0800
  Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-01 21:06 -0500
    Re: [union] Pointers to inherited structs are valid ? Tim Rentsch <txr@alumni.caltech.edu> - 2013-01-02 10:45 -0800
      Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-02 19:56 -0500
        Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-03 08:28 -0500
        Re: [union] Pointers to inherited structs are valid ? Tim Rentsch <txr@alumni.caltech.edu> - 2013-01-03 15:31 -0800
          Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-03 20:55 -0500
            Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-03 21:00 -0500
              Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-04 12:56 -0500
            Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-04 12:59 -0500
            Re: [union] Pointers to inherited structs are valid ? Tim Rentsch <txr@alumni.caltech.edu> - 2013-01-06 20:00 -0800
              Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-07 00:47 -0500
                Re: [union] Pointers to inherited structs are valid ? Tim Rentsch <txr@alumni.caltech.edu> - 2013-01-06 23:06 -0800
                Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-07 04:03 -0500
                Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-07 08:25 -0500
                Re: [union] Pointers to inherited structs are valid ? Tim Rentsch <txr@alumni.caltech.edu> - 2013-01-13 10:34 -0800
                Re: Off-Topic: Irritating Posting Patterns Shao Miller <sha0.miller@gmail.com> - 2013-01-13 16:00 -0500
                Re: Off-Topic: Irritating Posting Patterns Tim Rentsch <txr@alumni.caltech.edu> - 2013-01-14 12:27 -0800
              Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-07 07:41 -0500
                Re: [union] Pointers to inherited structs are valid ? Tim Rentsch <txr@alumni.caltech.edu> - 2013-01-12 14:52 -0800
                Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-13 15:19 -0500
                Re: [union] Pointers to inherited structs are valid ? Tim Rentsch <txr@alumni.caltech.edu> - 2013-01-14 12:04 -0800
                Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-14 18:52 -0500
                Re: [union] Pointers to inherited structs are valid ? Tim Rentsch <txr@alumni.caltech.edu> - 2013-01-16 00:01 -0800
                Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-16 05:43 -0500
                Re: [union] Pointers to inherited structs are valid ? Geoff <geoff@invalid.invalid> - 2013-01-16 09:01 -0800
                Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-16 18:32 -0500
                Re: [union] Pointers to inherited structs are valid ? Geoff <geoff@invalid.invalid> - 2013-01-16 17:32 -0800
                Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-16 20:57 -0500
                Re: [union] Pointers to inherited structs are valid ? Keith Thompson <kst-u@mib.org> - 2013-01-17 07:55 -0800
                Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-17 16:47 -0500
                Re: [union] Pointers to inherited structs are valid ? Keith Thompson <kst-u@mib.org> - 2013-01-18 08:41 -0800
                Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-18 15:53 -0500
                Re: [union] Pointers to inherited structs are valid ? Keith Thompson <kst-u@mib.org> - 2013-01-18 17:38 -0800
                Re: [union] Pointers to inherited structs are valid ? glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2013-01-19 02:31 +0000
                Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-18 23:15 -0500
                Re: [union] Pointers to inherited structs are valid ? Keith Thompson <kst-u@mib.org> - 2013-01-19 20:03 -0800
                Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-20 02:19 -0500
                Re: [union] Pointers to inherited structs are valid ? Keith Thompson <kst-u@mib.org> - 2013-01-20 07:57 -0800
                Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-20 15:25 -0500
                Re: [union] Pointers to inherited structs are valid ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2013-01-20 23:58 +0000
                Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-20 21:30 -0500
                Re: [union] Pointers to inherited structs are valid ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2013-01-21 02:53 +0000
                Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-21 00:05 -0500
                Re: [union] Pointers to inherited structs are valid ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2013-01-21 16:31 +0000
                Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-21 14:07 -0500
                Re: [union] Pointers to inherited structs are valid ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2013-01-21 21:05 +0000
                Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-21 17:13 -0500
                Re: [union] Pointers to inherited structs are valid ? Keith Thompson <kst-u@mib.org> - 2013-01-21 16:11 -0800
                Re: [union] Pointers to inherited structs are valid ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2013-01-22 04:59 +0000
                Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-22 01:05 -0500
                Re: [union] Pointers to inherited structs are valid ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2013-01-22 14:53 +0000
                Re: [union] Pointers to inherited structs are valid ? Keith Thompson <kst-u@mib.org> - 2013-01-22 08:38 -0800
                Re: [union] Pointers to inherited structs are valid ? Tim Rentsch <txr@alumni.caltech.edu> - 2013-01-21 20:53 -0800
                Re: [union] Pointers to inherited structs are valid ? Philip Lantz <prl@canterey.us> - 2013-01-22 00:58 -0800
                Re: [union] Pointers to inherited structs are valid ? Keith Thompson <kst-u@mib.org> - 2013-01-22 08:40 -0800
                Re: [union] Pointers to inherited structs are valid ? Tim Rentsch <txr@alumni.caltech.edu> - 2013-01-22 23:32 -0800
                Re: [union] Pointers to inherited structs are valid ? Philip Lantz <prl@canterey.us> - 2013-01-23 23:21 -0800
                Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-24 04:53 -0500
                Re: [union] Pointers to inherited structs are valid ? Tim Rentsch <txr@alumni.caltech.edu> - 2013-01-25 10:49 -0800
                Re: [union] Pointers to inherited structs are valid ? Keith Thompson <kst-u@mib.org> - 2013-01-22 08:25 -0800
                Re: [union] Pointers to inherited structs are valid ? Tim Rentsch <txr@alumni.caltech.edu> - 2013-01-22 23:41 -0800
                Re: [union] Pointers to inherited structs are valid ? Keith Thompson <kst-u@mib.org> - 2013-01-21 13:32 -0800
                Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-21 17:46 -0500
                Re: [union] Pointers to inherited structs are valid ? Keith Thompson <kst-u@mib.org> - 2013-01-22 07:43 -0800
                Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-22 16:07 -0500
                Re: [union] Pointers to inherited structs are valid ? Keith Thompson <kst-u@mib.org> - 2013-01-22 14:15 -0800
                Re: [union] Pointers to inherited structs are valid ? Keith Thompson <kst-u@mib.org> - 2013-01-22 14:31 -0800
                Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-22 21:32 -0500
                Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-23 17:17 -0500
                Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-23 19:49 -0500
                Re: [union] Pointers to inherited structs are valid ? Geoff <geoff@invalid.invalid> - 2013-01-23 18:55 -0800
                Re: [union] Pointers to inherited structs are valid ? Keith Thompson <kst-u@mib.org> - 2013-01-24 11:01 -0800
                Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-24 14:11 -0500
                Re: [union] Pointers to inherited structs are valid ? Geoff <geoff@invalid.invalid> - 2013-01-22 17:51 -0800
                Re: [union] Pointers to inherited structs are valid ? Philip Lantz <prl@canterey.us> - 2013-01-20 16:48 -0800
                Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-20 21:33 -0500
                Re: [union] Pointers to inherited structs are valid ? Tim Rentsch <txr@alumni.caltech.edu> - 2013-01-21 09:23 -0800
                Re: [union] Pointers to inherited structs are valid ? Keith Thompson <kst-u@mib.org> - 2013-01-20 17:07 -0800
                Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-20 22:20 -0500
                Re: [union] Pointers to inherited structs are valid ? Keith Thompson <kst-u@mib.org> - 2013-01-20 22:02 -0800
                Re: [union] Pointers to inherited structs are valid ? glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2013-01-21 07:00 +0000
                Re: [union] Pointers to inherited structs are valid ? James Kuyper <jameskuyper@verizon.net> - 2013-01-21 08:17 -0500
                Re: [union] Pointers to inherited structs are valid ? Dr Nick <nospam-4@temporary-address.org.uk> - 2013-01-21 14:13 +0000
                Re: [union] Pointers to inherited structs are valid ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2013-01-21 14:12 +0000
                Re: [union] Pointers to inherited structs are valid ? Keith Thompson <kst-u@mib.org> - 2013-01-21 08:20 -0800
                Re: [union] Pointers to inherited structs are valid ? glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2013-01-21 20:41 +0000
                Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-21 12:37 -0500
                Re: [union] Pointers to inherited structs are valid ? Keith Thompson <kst-u@mib.org> - 2013-01-21 12:17 -0800
                Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-21 16:33 -0500
                Re: [union] Pointers to inherited structs are valid ? Keith Thompson <kst-u@mib.org> - 2013-01-21 15:50 -0800
                Re: [union] Pointers to inherited structs are valid ? Tim Rentsch <txr@alumni.caltech.edu> - 2013-01-21 19:45 -0800
                Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-22 00:18 -0500
                Re: [union] Pointers to inherited structs are valid ? Keith Thompson <kst-u@mib.org> - 2013-01-22 08:01 -0800
                Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-18 23:02 -0500
                Re: [union] Pointers to inherited structs are valid ? Philip Lantz <prl@canterey.us> - 2013-01-19 01:28 -0800
                Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-19 12:08 -0500
                Re: [union] Pointers to inherited structs are valid ? Geoff <geoff@invalid.invalid> - 2013-01-21 09:27 -0800
                Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-21 12:46 -0500
                Re: [union] Pointers to inherited structs are valid ? glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2013-01-21 20:48 +0000
                Re: [union] Pointers to inherited structs are valid ? Geoff <geoff@invalid.invalid> - 2013-01-21 18:52 -0800
                Re: [union] Pointers to inherited structs are valid ? glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2013-01-22 04:07 +0000
                Re: [union] Pointers to inherited structs are valid ? Shao Miller <sha0.miller@gmail.com> - 2013-01-21 23:15 -0500
                Re: [union] Pointers to inherited structs are valid ? Tim Rentsch <txr@alumni.caltech.edu> - 2013-01-16 10:59 -0800
  Re: [union] Pointers to inherited structs are valid ? Tim Rentsch <txr@alumni.caltech.edu> - 2013-01-02 10:34 -0800

csiph-web