<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">Thank you!<br>
Now to change the XCore ABI instead...<br>
Educated and appreciative.<br>
Robert<br>
<br>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div style="direction: ltr;" id="divRpF346307"><font color="#000000" face="Tahoma" size="2"><b>From:</b> metafoo@gmail.com [metafoo@gmail.com] on behalf of Richard Smith [richard@metafoo.co.uk]<br>
<b>Sent:</b> 30 July 2013 20:33<br>
<b>To:</b> Robert Lytton<br>
<b>Cc:</b> cfe-dev@cs.uiuc.edu; benny.kra@gmail.com<br>
<b>Subject:</b> Re: [cfe-dev] different signedness for bitfield 'char' and plain 'char'<br>
</font><br>
</div>
<div></div>
<div>On Tue, Jul 30, 2013 at 12:27 PM, Robert Lytton <span dir="ltr"><<a href="mailto:robert@xmos.com" target="_blank">robert@xmos.com</a>></span> wrote:<br>
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div>
<div style="direction:ltr; font-size:10pt; font-family:Tahoma">Hi Richard,<br>
<br>
I only have access to a working draft of the C++11 standard (N3242=11-0012, date 2011-02-28)<br>
All I can find is as quoted before:
<div class="im"><br>
9.6:p3<br>
It is implementation-defined whether a plain (neither explicitly signed nor unsigned) char, short, int or long bit-field is signed or unsigned.<br>
</div>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>This text was removed by DR739:</div>
<div><br>
</div>
<div><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#739" target="_blank">http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#739</a></div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div>
<div style="direction:ltr; font-size:10pt; font-family:Tahoma">
<div class="im"></div>
I've tried finding any further statement but have not been successful.<br>
Please could you direct me to the relevant clause.<br>
<br>
robert<br>
<br>
<div style="font-size:16px; font-family:Times New Roman">
<hr>
<div style="direction:ltr"><font color="#000000" face="Tahoma">
<div class="im"><b>From:</b> <a href="mailto:metafoo@gmail.com" target="_blank">metafoo@gmail.com</a> [<a href="mailto:metafoo@gmail.com" target="_blank">metafoo@gmail.com</a>] on behalf of Richard Smith [<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>]<br>
</div>
<b>Sent:</b> 30 July 2013 20:21
<div>
<div class="h5"><br>
<b>To:</b> Robert Lytton<br>
<b>Cc:</b> <a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a>;
<a href="mailto:benny.kra@gmail.com" target="_blank">benny.kra@gmail.com</a><br>
<b>Subject:</b> Re: [cfe-dev] different signedness for bitfield 'char' and plain 'char'<br>
</div>
</div>
</font><br>
</div>
<div>
<div class="h5">
<div></div>
<div>On Tue, Jul 30, 2013 at 12:12 PM, Robert Lytton <span dir="ltr"><<a href="mailto:robert@xmos.com" target="_blank">robert@xmos.com</a>></span> wrote:<br>
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div>
<div style="direction:ltr; font-size:10pt; font-family:Tahoma">Hi Richard,
<div><br>
<br>
<div>> What standard? C++ requires that bit-fields have the same signedness as their underlying type. If 'char' is unsigned, then bit-fields of type 'char' are also unsigned.</div>
</div>
Sorry, I was thinking of the C99 standard.<br>
But I actually was half quoting c++ 2011 standard.<br>
Either way, I was wrong - but still not clear.<br>
<br>
The XCore ABI (currently implemented by the XCore llvm-gcc frontend) expects:
<div><br>
'char' to be unsigned.<br>
but the bit field 'char' to be signed.<br>
<br>
</div>
Does this infringe the C99 & C++11 standards?<br>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>This is fine in C99, but not permitted by C++11 (and arguably, because the relevant DR applied to all versions of C++, is also not permitted in any earlier version of C++ either).</div>
<div><br>
</div>
<div>Note that the x86_64 ABI also claims that plain (neither signed nor unsigned) bit-fields are unsigned, but it is simply wrong. Maybe the XCore ABI document is wrong too?</div>
<div><br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div>
<div style="direction:ltr; font-size:10pt; font-family:Tahoma">I'll keep reading but I'm no lawyer.<br>
<br>
robert<br>
<br>
C++<br>
9.6:p3<br>
It is implementation-defined whether a plain (neither explicitly signed nor unsigned) char, short, int or long bit-field is signed or unsigned.<br>
<br>
C99<br>
6.2.5:p15<br>
The three types char, signed char, and unsigned char are collectively called the character types. The implementation shall define char to have the same range, representation, and behavior as either signed char or unsigned char.<br>
6.7.2:p5<br>
Each of the comma-separated sets designates the same type, except that for bit-fields, it is implementation-defined whether the specifier int designates the same type as signed int or the same type as unsigned int.<br>
6.7.2.1:p9<br>
A bit-field is interpreted as a signed or unsigned integer type consisting of the specified number of bits. 105<br>
105) As specified in 6.7.2 above, if the actual type specifier used is int or a typedef-name defined as int, then it is implementation-defined whether the bit-field is signed or unsigned.<br>
<br>
<br>
<div style="font-size:16px; font-family:Times New Roman">
<hr>
<div style="direction:ltr"><font color="#000000" face="Tahoma"><b>From:</b> <a href="mailto:metafoo@gmail.com" target="_blank">
metafoo@gmail.com</a> [<a href="mailto:metafoo@gmail.com" target="_blank">metafoo@gmail.com</a>] on behalf of Richard Smith [<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>]<br>
<b>Sent:</b> 30 July 2013 19:19<br>
<b>To:</b> Robert Lytton<br>
<b>Cc:</b> <a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a>;
<a href="mailto:benny.kra@gmail.com" target="_blank">benny.kra@gmail.com</a><br>
<b>Subject:</b> Re: [cfe-dev] different signedness for bitfield 'char' and plain 'char'<br>
</font><br>
</div>
<div>
<div>
<div></div>
<div>On Tue, Jul 30, 2013 at 10:51 AM, Robert Lytton <span dir="ltr"><<a href="mailto:robert@xmos.com" target="_blank">robert@xmos.com</a>></span> wrote:<br>
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div>
<div style="direction:ltr; font-size:10pt; font-family:Tahoma">Hi,<br>
<br>
I have altered<font> <span style="font-size:10pt"><font><span style="font-size:10pt"></span></font>isSignedCharDefault() to make 'char' unsigned for the xcore target too.<br>
(The signedness of 'char' is an ABI issue as far a the standard is concerned.)<br>
<br>
</span></font>My problem now is that char-bitfields are also being made unsigned.<br>
According to the standard the members of a bitfield are always signed unless explicitly marked unsigned.<br>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>What standard? C++ requires that bit-fields have the same signedness as their underlying type. If 'char' is unsigned, then bit-fields of type 'char' are also unsigned.</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div>
<div style="direction:ltr; font-size:10pt; font-family:Tahoma">Hence I need:<br>
'char' to be unsigned.<br>
but the bit field 'char' to be signed.<br>
<br>
viz:<br>
// ABI requires plain 'char' to be unsigned<br>
char c = (char)-1;<br>
assert(c >= 0);<br>
<br>
// members of a bitfield are always signed unless explicitly marked unsigned<br>
struct char_sign { char x : 1; };<br>
char_sign.x = 1;<br>
assert(char_sign.x < 0);<br>
<br>
<br>
Is this possible in clang?<br>
If not, could anyone like to point me in the right direction to where the fix would be necessary?<br>
<br>
Thank you<span><font color="#888888"><br>
<br>
Robert<br>
<br>
<br>
</font></span></div>
</div>
<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</body>
</html>