Skip to content

"multi-character character constant" warning is not displayed for 4-character constants #137471

Open
@strimo378

Description

@strimo378

Hi all,

I found an inconsistency in the warning of multi-character constants. In the following code, the first 2 cases produce a warning while the third one does not:

int x2 = '\x12\x34';
int x3 = '\x12\x34\x56';
int x4 = '\x12\x34\x56\x78';

This code outputs

<source>:3:10: warning: multi-character character constant [-Wmultichar]
    3 | int x2 = '\x12\x34';
      |          ^
<source>:4:10: warning: multi-character character constant [-Wmultichar]
    4 | int x3 = '\x12\x34\x56';

See compiler explorer: https://godbolt.org/z/7ce7qW46f

gcc is showing 3 warnings.

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