Bug 106528 - Double semi-colon causes -Wmisleading-identation to not emit warning
Summary: Double semi-colon causes -Wmisleading-identation to not emit warning
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 12.1.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2022-08-04 18:21 UTC by Dylan Baker
Modified: 2022-08-09 12:41 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dylan Baker 2022-08-04 18:21:15 UTC
A double semi-colon will cause the misleading-indentation warning to miss that a second indented statement is not part by the condiational block.

#include <stdio.h>

int main(void) {
    if (1)
        printf("%s", "true);;
        return 0;
    return 1;

Removing the extranious semi-colon from the printf() call will correct the problem and gcc will emit a warning as expected.

I've tested with 11.3.1 and 12.1.0, and with clang 14, which has the same behavior. This was noticed through a macro that adds a semi-colon in the macro definition, and then has a semi-colon following the call to the macro.