@dcoughlin I'm curious whether you'd like such a change: in general, I think it is much better when the assert failure tells the developer _what_ value is failing, rather than saying "oops we are dead".
I would personally even go further with providing a templated function from dump-able object to a string, which could be used to avoid such a cumbersome construction [which I have seen in a few places in Clang]
Details
Diff Detail
Event Timeline
I think it is much better when the assert failure tells the developer _what_ value is failing, rather than saying "oops we are dead".
yes of course, more informative assert messages is better.
What is the workflow where this is needed? Is it when an end-user is running a build with assertions and can't provide a reproducer but can provide the console output?
Does llvm_unreachable() guarantee that the string construction code is completely removed from release builds?
Is it when an end-user is running a build with assertions and can't provide a reproducer but can provide the console output?
Yes, or just for developer staring at the crash for the first time, or for the crashers in CI.
Does llvm_unreachable() guarantee that the string construction code is completely removed from release builds?
I am not sure what do you mean, the string construction code would only be encountered when we are in the default branch, which would mean that we are crashing already. Or do you worry about the code size being slightly larger?
Does llvm_unreachable() guarantee that the string construction code is completely removed from release builds?
http://llvm.org/docs/CodingStandards.html#assert-liberally:
When assertions are disabled (i.e. in release builds), llvm_unreachable becomes a hint to compilers to skip generating code for this branch. If the compiler does not support this, it will fall back to the “abort” implementation.
So i think it's fine. Not sure how much time it saves compared to writing these dumps (as a *lot* of places would need those).
Personally, I don't think this is worth it and I find it unpleasant to add untestable code -- especially if that code is going to stick around in release builds.
@dcoughlin OK, I guess you could theoretically come up with a scenario where an error in this code would lead to crashing-while-crashing which would obscure the original error.