Skip to content

[clang][Sema] Question: Why is -Wshorten-64-to-32 disjoint from -Wimplicit-int-conversion? #69444

@whisperity

Description

@whisperity

An interesting case was encountered where conversions from larger bit-width integers to smaller bit-width ones is generally reported by -Wimplicit-int-conversion (32 to 16, 16 to 8, 128 to 64, etc.) except for 64 to 32, which was given its own warning: -Wshorten-64-to-32.

See http://godbolt.org/z/6q4GMPsxs. Lines 19 (uint64_t -> uint32_t) and 35 (int64_t -> int32_t) are not warned about, unless "Compiler 2"'s warning is enabled.

Although -Weverything enables both of them at the same time (and neither is enabled by default, AFAIK), it is strange that 64->32 is such a specific dedicated case.

Unfortunately, all I could track down was commit 263a48b where this warning was introduced, and that is ancient, but history runs dry at that point.

CC @dwblaikie, @rjmccall. Your names appeared in the relevant code path.


What would be the cons against enabling -Wshorten-64-to-32 under -Wimplicit-int-conversion implicitly?

Metadata

Metadata

Assignees

No one assigned

    Labels

    c++clang:frontendLanguage frontend issues, e.g. anything involving "Sema"enhancementImproving things as opposed to bug fixing, e.g. new or missing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions