For example 6.5.2.2 suggests that the call is okay, because the
promoted argument type (int) is compatible with the promoted parameter
Is there an online reference for
6.5.2.2, et al.? I don't have a dead-tree version handy and would be more than happy to research such things myself before posting questions.
My guess is that it _is_ a tcc bug. The best and easist workaround is
to never use old-style function definitions in the first place. It's
been 17 years since prototypes were standardized, after all.
I absolutely agree with you here.
Thank you very much for your well explained and referenced answer! I truly appreciate the effort you spent.
> long double ld = 3.14;
[...]
> printf("%lf\n", ld);
For long double you should use %Lf, not %lf. Also, keep in mind that
the actual implementation of "printf" is provided by the system's C
library, not tcc.
This answer gave me pause for a while until I realized you meant that when the TCC binary was compiled, it was _that_ compiler that is responsible. In the Windows binary port mentioned on the TCC page
http://fabrice.bellard.free.fr/tcc/
It appears that using either %lf or %Lf has the same result when passed a long double. Both show -
30329013470004487000000000000000000000000000.000000 when long double ld = 3.14; is passed in. So I'll just stick with double I don't have actual reasons for using long double, but was putting TCC through the paces.
Do you have an online reference for the right printf arguments? The one I found was on
msdn.microsoft.com and said that both %lf and %Lf were equivalent and both took long double. I also happen to know that in the compilers from them, long double and double are not different, so perhaps that's part of the strangeness.
Again, thank you ever so much for your response.