------- Comment #21 from rob1weld at aol dot com 2007-06-24 12:22 ------- (In reply to comment #20) > > Since GCC can 'see' the "%f" at compile time > ... that does not mean the behavior is the correct to cast it to float. ...
So the correct behavior is: a): Cast it to something other than float. - if it can only be float (in the example, otherwise anything else) as far as printf is concerned then why do that? I know you are NOT suggesting that we could cast it to (int) and use "%f" to print it and you are NOT suggesting that we could cast it to (char *), a string, and print it with "%f". - If the printf contains "%f" then the var "must" be a float. Example: long double A = 123.456; int B = A; Is the variable B an int, or something else. Why is it incorrect behaviour to print it with %f even if that means we get (a compiler warning when compiling and) 123.000 for output - would anyone prefer gibberish for output ? b): do as I suggested and avoid the security issue, bad output, and the need for contorted code (as shown in comment #18). c): The Emperor's clothes look wonderful. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32448