This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fix sign extension in cpplex.c



Andreas Jaeger wrote:

>"Ulrich Weigand" <Ulrich.Weigand@de.ibm.com> writes:
>
>> Hmm, as it is supposed to test sign extension, maybe we should
>> simply add a
>>
>>   /* { dg-options "-fsigned-char" } */
>>
>> to the test case?
>
>That shouldn't make a difference since the code already uses
>signed/unsigned explicitly:
>  signed char c = '\xff';
>  unsigned char d = '\xff';

It makes a difference in how the *constant* is interpreted:
with -fsigned-char, '\xff' is equivalent to -127, while with
-funsigned-char, '\xff' is equivalent to 255 ...

See section 6.4.4.4.10 of the standard: "If an integer character
constant contains a single character or escape sequence, its value
is the one that results when an object with type char whose value
is that of the single character or escape sequence is converted to
type int."


Mit freundlichen Gruessen / Best Regards

Ulrich Weigand

--
  Dr. Ulrich Weigand
  Linux for S/390 Design & Development
  IBM Deutschland Entwicklung GmbH, Schoenaicher Str. 220, 71032 Boeblingen
  Phone: +49-7031/16-3727   ---   Email: Ulrich.Weigand@de.ibm.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]