Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

-Wpadded may be split in two options #22816

Copy link
Copy link
Open
@llvmbot

Description

@llvmbot
Issue body actions
Bugzilla Link 22442
Version unspecified
OS All
Reporter LLVM Bugzilla Contributor
CC @davidstone,@rnk,@seanm,@Trass3r

Extended Description

Hello.

-Wpadded warns about two issues, padding a struct field and padding at the end (i.e: the whole struct). See the example:

struct Bidule
{
	char b;
	int a;
	char c;
};
test.cpp:4:6: warning: padding struct 'Bidule' with 3 bytes to align 'a' [-Wpadded]
        int a;
            ^
test.cpp:1:8: warning: padding size of 'Bidule' with 3 bytes to alignment boundary [-Wpadded]
struct Bidule

Usually padding in the middle is a bad thing because the struct can be "easily" organized differently to reduce the memory footprint. On the other hand, padding at the end of a structure is common and there is usually no trivial fix.

As an example, I ran -Wpadded on a large code base, I found 3 padding of field which I fixed, and more than one thousand warning messages about padding of struct for which I cannot do something without complex code refactoring.

It may be possible to split -Wpadding in two options, one which warns about padding fields (which I found really useful 100% of the time) and the other which warns about padding the whole struct, which IMHO only need to be activated when needed.

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaIssues migrated from bugzillaclang: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 party

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.