17 Jan 2004 haruspex   » (Journeyer)

mathieu: You ran,
        signed char x = (signed char)-1000000;
        printf ("%hhd\n", x);
        printf ("%hhd\n", -1000000);
and presumably you saw, like I do,
-64
-1000000
man printf on this Debian system does not specify whether the argument is really supposed to be narrowed to char, but the glibc manual interprets C99 to mean:
hh
Specifies that the argument is a signed char or unsigned char, as appropriate. A char argument is converted to an int or unsigned int by the default argument promotions anyway, but the h modifier says to convert it back to a char again.
...which would support your suspicion that the runtime behaviour is wrong (and the argument should be narrowed before printing).

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!