------- Comment #22 from manu at gcc dot gnu dot org 2008-01-16 12:36 ------- (In reply to comment #21) > (In reply to comment #20) > > Anyway, if you really want to believe that printf("%s\n",s) and puts(s) > > should > > not have the same effect for defined behaviour, then we will have to agree > > to > > disagree. > > That's confused, what is being discussed is undefined behavior X optimization > trusting it.
No, if we follow your reasoning, as you repeat constantly, "It is not undefined, per glibc." > Still, the manpage for puts() says "output of characters and > strings", while the one for printf() says "formatted output conversion". > puts() > just sends a string to stdout, printf() converts data into their string > representation. So I agree to disagree about the expectation on what they do > about NULL: puts() should do nothing or merely return error, while printf() > *could* convert or otherwise print a string representation of it. Finally, we agree about something. :-) Anyway, this has little to do with this bug. This is my personal opinion on how glic could fix if they really wanted. I guess other GCC developers think: "There is nothing to fix, expecting something from undefined behaviour is wrong and the optimisation is valid for all defined cases". > Given the impasse, and given Glibc defines what it does, I understand the next > correct thing for someone who cares to do, is to report a bug on GCC about > this > issue on any specific distributions using GCC together with Glibc. What you want us to do? We should avoid optimising printf("%s\n", s) to puts(s) just because s may be NULL? So, in your opinion, we should punish people that don't rely on printf("%s\n", NULL) being defined, and defined as something different as puts(NULL)? Sorry, we disagree. You are welcome to waste your (and others people) time reporting duplicated bugs. We will point them to this discussion. I think there is far enough information here and, in particular, in http://sourceware.org/bugzilla/show_bug.cgi?id=5618 , for anyone to make their own opinion about the issue. If distributions want to patch GCC or use -fno-builtin-printf by default, they are allow to do it. Good luck with that. Please, I am sure you are not that kind of internet character that needs to have the last word on everything, so accept that this is closed. Thanks. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25609