<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>C addresses some of this very simply and thoroughly:<BR> 1) layout of bitfields is implementation independent<br> 2) I think even the ability to declare some bitfields is not guaranteeed,<br>  e.g. int a : 33<br> 3) You can't take the address of bitfields. This is the key one I think.<br> 4) Bitfields can only occur in structs/unions, not in typedefs,<br> variables, parameters, return types, etc.<BR><br> - Jay<br><br><br><br> <BR><div><hr id="stopSpelling">From: jay.krell@cornell.edu<br>To: rodney_bates@lcwb.coop; m3devel@elegosoft.com<br>Date: Sun, 22 Sep 2013 17:47:07 +0000<br>Subject: Re: [M3devel] what does it mean to read a UINT8?<br><br>

<style><!--
.ExternalClass .ecxhmmessage P {
padding:0px;
}

.ExternalClass body.ecxhmmessage {
font-size:12pt;
font-family:Calibri;
}

--></style>
<div dir="ltr">UINT8 is [0..255] I think.<br>I tried "BITS 8 FOR" on it at some point but such things on that family of types (UINT16, UINT32, UINT64) caused compilation errors. (These are all via Ctypes.i3)<br><br>The pointer before subtraction is 64K-aligned.<br><br>I don't think the other types should matter.<br><br>I still have to compare with integrated backend or cm3cg.<br> <br> - Jay<br><br>> Date: Sun, 22 Sep 2013 12:17:18 -0500<br>> From: rodney_bates@lcwb.coop<br>> To: m3devel@elegosoft.com<br>> Subject: Re: [M3devel] what does it mean to read a UINT8?<br>> <br>> As in my other response, I think you are left entirely too much<br>> out in the wind by the language/compiler as to what your expectations<br>> should be. In this particular example, it would help to know the type<br>> UINT8, and those of 'used', 'info', 'RegionSize', and maybe 'b'.  I<br>> could make some guesses, but that could turn out a snipe hunt.<br>> <br>> Do you mean it copies a full INTEGER into b, or just fetches<br>> an INTEGER, then extracts from it?  What is the alignment of<br>> the actual address in the failing case?<br>> <br>> On 09/21/2013 10:58 PM, Jay K wrote:<br>> > It appears that this code:<br>> ><br>> ><br>> > b := LOOPHOLE(used + info.RegionSize - 1, UNTRACED REF UINT8)^;<br>> ><br>> ><br>> > generates a read of a full INTEGER, in this case 8 bytes.<br>> ><br>> ><br>> > Now, I know, I could change it to:<br>> ><br>> ><br>> > b := LOOPHOLE(used + info.RegionSize - BYTESIZE(INTEGER), UNTRACED REF INTEGER)^;<br>> ><br>> ><br>> > What were my expectations wrong in the first place?<br>> ><br>> ><br>> > This code was part of getting stack bounds and it'd read<br>> > the end of the stack to try to ensure it was correct.<br>> ><br>> ><br>> > I removed it.<br>> ><br>> ><br>> > 0:000> g<br>> > (15bc.116c): Access violation - code c0000005 (first chance)<br>> > First chance exceptions are reported before any exception handling.<br>> > This exception may be expected and handled.<br>> > *** WARNING: Unable to verify checksum for cm3.exe<br>> > cm3!ThreadWin32__GetStackBounds+0x1e8:<br>> > 00000001`3fdf1a78 488b48ff        mov     rcx,qword ptr [rax-1] ds:00000000`0028<br>> > ffff=????????????????<br>> > 0:000> r rax<br>> > rax=0000000000290000<br>> > 0:000> r rsp<br>> > rsp=000000000028fb60<br>> > 0:000> dv<br>> >      start_L_275 = 0x00000000`00338de0<br>> >        end_L_276 = 0x00000000`00338de8<br>> >      L_501_L_502 = 0n48<br>> >       used_L_272 = 0x00000000`0028f000<br>> > available_L_273 = 0x00000000`00190000 "--- memory read error at address 0x000000<br>> > 00`00190000 ---"<br>> >          b_L_274 = 0x30 '0'<br>> >          a_L_271 = 0n48<br>> >       info_L_270 = struct TA669C7A1<br>> >           _frame = struct ThreadWin32__GetStackBounds_Frame_t<br>> > 0:000> ?? info_L_270<br>> > struct TA669C7A1<br>> >     +0x000 BaseAddress      : 0x00000000`0028f000  "0???"<br>> >     +0x008 AllocationBase   : 0x00000000`00190000  "--- memory read error at addr<br>> > ess 0x00000000`00190000 ---"<br>> >     +0x010 AllocationProtect : 4<br>> >     +0x014 L_7              : [4]  ""<br>> >     +0x018 RegionSize       : 0n4096<br>> >     +0x020 State            : 0x1000<br>> >     +0x024 Protect          : 4<br>> >     +0x028 Type             : 0x20000<br>> >     +0x02c L_8              : [4]  ""<br>> > 0:000> q<br>> > quit:<br>> ><br>> ><br>> >   - Jay<br>> <br>                                       </div></div>                                        </div></body>
</html>