3 ms·
> I wonder how many people worry about supplying clang a file that doesn't end in a new line? That is undefined behaviour It no longer is, since C++11. Check P
by MauranKilom 8y ago
> I wonder how many people worry about supplying clang a file that doesn't end in a new line? That is undefined behaviour
It no longer is, since C++11. Check Phase 2.2 here: https://en.cppreference.com/w/cpp/language/translation_phases https://en.cppreference.com/w/cpp/language/translation_phase...
> clang won't delete your source file, even though it would be perfectly within its rights to.
UB allows the execution of the compiled program to wipe your hard drive, but it certainly does not give your compiler that right. I mean, the standard doesn't say what side effects invoking a compiler is allowed to have (because that's out of scope), so none of it can be predicated on UB.
(Mandatory mention: https://github.com/munificent/vigil https://github.com/munificent/vigil)
- tom_ 8y agoThanks for the clarification. An outbreak of good sense? I hope it's contagious. It is still undefined behaviour in C11. Not sure I agree with you about UB - missing line-endings is a parse-time issue, so the intent appears to be that the compiler (or interpreter) is free to do what it likes even at this stage, before your program is even ready to run.