[cfe-dev] confusion with character types
Bruce Stephens
bruce.r.stephens at gmail.com
Thu Oct 14 07:23:45 PDT 2010
Jochen Wilhelmy <j.wilhelmy-KvP5wT2u2U0 at public.gmane.org> writes:
>>But would it be better if this gave a different result?
>>
>> signed char n = '\n';
>> std::cout<< "Hello world"<< n;
>
> of course ;-)
> these are equivalent:
> signed char n = '\n';
> int8_t n = '\n';
> int8_t n = 10;
>
> therefore I would expect "Hello world10".
>
> it's the same as this being different:
> float n = '\n';
> std::cout<< "Hello world"<< n;
Perhaps, though I tend to think (apparently not entirely correctly) of
"char" as being equivalent to either "signed char" or "unsigned char".
In any case there's nothing that clang/libcxx ought to do. The standard
is what it is. (Perhaps a stream which handles signed and/or unsigned
chars differently would be useful and that seems like a plausible
extension, but I doubt it's really worth adding.)
More information about the cfe-dev
mailing list