This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Silence warning about padding inserted at the tail of struct _Rep_base
AbandonedPublic

Authored by ahatanak on Jan 5 2016, 11:51 AM.

Details

Summary

This patch fixes a warning that is issued when -Wpadded is on clang's command line. The following warning is from the build log of http://lab.llvm.org:8080/green/view/Libcxx/job/libcxx_abi/554/consoleText (note that I see this warning issued only from builders that use lib/buildit):

In file included from ../src/stdexcept.cpp:10:
../include/__refstring:30:12: warning: padding size of 'std::1::libcpp_refstring::_Rep_base' with 4 bytes to alignment boundary [-Wpadded]

struct _Rep_base
       ^

1 warning generated.

Diff Detail

Event Timeline

ahatanak updated this revision to Diff 44032.Jan 5 2016, 11:51 AM
ahatanak retitled this revision from to [libc++] Silence warning about padding inserted at the tail of struct _Rep_base.
ahatanak updated this object.
ahatanak added a subscriber: cfe-commits.

Ping.

The same pragma is being used in other places (regex.cpp and locale.cpp) to silence the warning.

Maybe we can just remove -Wpadded from buildit's command line for now? If we decide in the future it's worthwhile to use -Wpadded, we can put it back and commit this patch. Also in that case we should make sure cmake uses the option too.

joerg edited edge metadata.Jan 26 2016, 4:10 AM

As I said on IRC, it might be useful to set -Wpadding -Wno-error=padding, but I don't think the current state adds value. So removing the option is certainly an acceptable step forward to me.

Do you mean "-Wpadded -Wno-error=padded" instead of padding?

I'm looking for a way to silence the warning, so that isn't enough. If we need more time to decide whether we want to use -Wpadded (for both buildit and cmake), I think I'll just remove -Wpadded from buildit's command line for now.

There is also a PR about splitting -Wpadded into two options: one warns about padding in the middle of a struct and the other warns about padding at the end. If the former option is used instead of -Wpadded, I believe it's possible to remove the pragmas that are currently used in libc++.

https://llvm.org/bugs/show_bug.cgi?id=22442

ahatanak abandoned this revision.Jan 26 2016, 6:01 PM

Abandoning this patch as I've removed -Wpadded in r258900.