UB in example code for E0617 #86908
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
I was browsing through some errors and I noticed the explanation for E0617:
(replaced backticks with quotes to fix the formatting issues)
The diagnostic itself is fine and correctly suggests how to fix the error, however I think the code in question is troublesome - passing a null pointer to
printf
is undefined behavior! As a language that prides itself in avoiding UB, I find it odd that the documentation would make a mistake like that. I think that the nullptr could also be a distraction to the reader.On further discussion, someone also pointed out that the presented signature of
printf
is wrong, because it should have an integer return type.Perhaps these issues could be fixed by replacing
printf
with a dummy functionfoo
that takes variadic arguments only? In my opinion, it would make a cleaner explanation overall.The text was updated successfully, but these errors were encountered: