On 7 Dec 2003 21:57:53 -0800,
co****@lawyer.com (conrad) wrote in
comp.lang.c:
for something like printf("%lld\n", 1);
what section in the standard describes what type the argument "1"
is promoted to?
All I see is a section describing promotion from
float to double but nothing else.
There is no promotion of the of the argument. The numeric literal "1"
has the type signed int, and it is passed as a signed int.
The promotion rules for the *printf() functions are the same as those
for any other variadic function. Any argument of a lesser rank than
int or signed int gets promoted to either signed or unsigned int. Any
argument of type float gets promoted to double. Any other argument
type is unchanged. The format string has absolutely no impact on the
conversion rules, although some compilers have an option to check them
for you.
So the printf() call you wrote has undefined behavior because it
passes a signed int with a conversion specifier of signed long long.
If you want to print the numeric literal '1' as a signed long long,
you need to write it as 1LL or (long long)1.
--
Jack Klein
Home:
http://JK-Technology.Com
FAQs for
comp.lang.c
http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++
http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
ftp://snurse-l.org/pub/acllc-c++/faq