-
Notifications
You must be signed in to change notification settings - Fork 15.6k
Closed as duplicate of#111509
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillac++clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerconfirmedVerified by a second partyVerified by a second partyduplicateResolved as duplicateResolved as duplicatefalse-positiveWarning fires when it should notWarning fires when it should not
Description
| Bugzilla Link | 39026 |
| Version | 6.0 |
| OS | Linux |
| Reporter | LLVM Bugzilla Contributor |
| CC | @DougGregor |
Extended Description
Consider the following code:
int foo()
{
for (int y = 0; !y;)
for (/*decl*/; !y; ++y)
return 1;
}
This generates a -Wreturn-type warning, despite that the inner loop body will always execute. Moreover, with optimization enabled, the compiler does (as expected) successfully remove the loops entirely.
(This is a simplified version of a pre-C++17 with statement. The purpose of this code, which is usually a macro, is to look like the opening statement of a block, where /*decl*/ — omitted in this example — is in scope only until the end of the block. FWIW, the C++17 form, if (/*decl*/; true) does not exhibit the problem.)
Metadata
Metadata
Assignees
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillac++clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerconfirmedVerified by a second partyVerified by a second partyduplicateResolved as duplicateResolved as duplicatefalse-positiveWarning fires when it should notWarning fires when it should not