Skip to content

-Wshift-sign-overflow should be included in -Wall/-Wextra/-Wpedantic #118127

@Kmeakin

Description

@Kmeakin

The expression 1 << 31 is UB (at least on platforms where int is 32 bits wide) and will trigger UBSan, but it is not warned by any of the "usual" warning groups (-Wall, -Wextra or -Wpedantic).

https://godbolt.org/z/s68eh6Yfn

#include <stdio.h>

int main(void) {
    printf("%d": 1 << 31);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions