Article View: comp.std.c++
Article #1211Re: Zero-length structures and pointer comparisons
From: Jim Adcock
Date: Fri, 11 Dec 1992 23:30
Date: Fri, 11 Dec 1992 23:30
16 lines
1152 bytes
1152 bytes
In article <KANZE.92Dec10174617@slsvdnt.us-es.sel.de> kanze@us-es.sel.de (James Kanze) writes: |We already *have* this function. Try the following: | | void* ptr1 ; | void* ptr2 ; | int cmp = memcmp( &ptr1 , &ptr2 , sizeof( void* ) ) ; | |This works on all implementations I can think of. Is it guaranteed? |(Ie: can pointers also hold undefined padding information which may |vary in a random fashion. Note that "memcmp" is *not* guaranteed to |work on struct's.) Not guaranteed, nor does there have to be random padding for it to not be guaranteed. All the bits could be used, but there could be multiple bit combinations mapping to the same underlying memory address. Early PCs and OSs being an example.
Technical Details
Message-ID:
<1992Dec11.233039.12249@microsoft.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!microsoft!hexnut!jimadReferences:
<1992Dec8.103218.27689@lth.se> <9234423.15066@mulga.cs.mu.OZ.AU> <KANZE.92Dec10174617@slsvdnt.us-es.sel.de>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c++ Path: arc1-ca.pugleaf.net!sparky!uunet!microsoft!hexnut!jimad From: jimad@microsoft.com (Jim Adcock) Subject: Re: Zero-length structures and pointer comparisons Message-ID: <1992Dec11.233039.12249@microsoft.com> Date: 11 Dec 92 23:30:39 GMT Organization: Microsoft Corporation References: <1992Dec8.103218.27689@lth.se> <9234423.15066@mulga.cs.mu.OZ.AU> <KANZE.92Dec10174617@slsvdnt.us-es.sel.de> Lines: 17