-
-
Notifications
You must be signed in to change notification settings - Fork 15k
UB in example code for E0617 #86908
Copy link
Copy link
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
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
printfis 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
printfis wrong, because it should have an integer return type.Perhaps these issues could be fixed by replacing
printfwith a dummy functionfoothat takes variadic arguments only? In my opinion, it would make a cleaner explanation overall.