Quotes of the week
Quotes of the week
Posted Jun 3, 2021 14:39 UTC (Thu) by khim (subscriber, #9252)In reply to: Quotes of the week by rschroev
Parent article: Quotes of the week
> I'm asking because I'm not sure how to interpret 'the only possible output is "2 2"'.
Ah, sorry. I actually forgot about the fact that realloc
can, according to the standard, actually return a different address here. In practice all existing implementations return the same one.
Yes, correctly compiled program may return empty output here if, e.g. you realloc
just always calls malloc
and copies the content. That's not an issue.
The issue is: actual output (that is: 1 2
) is clearly invalid.
Clang, MSVC and ICC all produce "1 2\n" output and they all claim that they can do that because they plan to add new set of undefined hehaviors to the C2x standard.
Once again: they miscompile perfectly valid C89 program in a strict C89 mode today and claim that it's fine because it, apparently, violates set of rules which they plan to add to C2x (and which is not yet even finalized).
And the explicitly refuse to provide any flags which can make it work (although -fno-builtin-realloc works, but it's extremely unituitive and non-obvious
Posted Jun 3, 2021 15:13 UTC (Thu)
by rschroev (subscriber, #4164)
[Link]
And now I see that you made that clarification already elsewhere in the thread. Sorry, my bad.
Quotes of the week