[libcxx-commits] [PATCH] D65034: [libc++] use constexpr for sizeof comparisons

Alan Somers via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Mar 26 06:28:31 PDT 2020


asomers added a comment.

In D65034#1941584 <https://reviews.llvm.org/D65034#1941584>, @ldionne wrote:

> In D65034#1941567 <https://reviews.llvm.org/D65034#1941567>, @asomers wrote:
>
> > In D65034#1941477 <https://reviews.llvm.org/D65034#1941477>, @ldionne wrote:
> >
> > > Looking at this again and the corresponding GCC bug report, I think we should either:
> > >
> > > - not fix this issue -- this warning shouldn't bubble up since we mark our headers as system headers, or
> > > - disable `-Wplacement-new` around that code with a `#pragma`, and reference the GCC bug in a comment.
> >
> >
> > Well, the warning does bubble up.  I ran into this when using GCC to build FreeBSD for riscv64.
>
>
> Can you show me how you're building the file that produces a warning? Normally, our headers shouldn't bubble up warnings cause we use the `#pragma system header` on GCC. If that doesn't work, then either their warning doesn't listen to the pragma, or something else is happening. Either way, I'd like to understand before we change any code.


Here's the command line that built the offending file:

  /usr/local/bin/riscv64-unknown-freebsd13.0-g++  --sysroot=/scratch/tmp/asomers/obj/home/asomers/freebsd/base/head/riscv.riscv64/tmp -B/usr/local/riscv64-unknown-freebsd13.0/bin/  -O2 -pipe -march=rv64imafdc -mabi=lp64d -g -Wno-format-zero-length -fstack-protector-strong -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline -Wredundant-decls -Wno-error=address -Wno-error=array-bounds -Wno-error=attributes -Wno-error=bool-compare -Wno-error=cast-align -Wno-error=clobbered -Wno-error=deprecated-declarations -Wno-error=enum-compare -Wno-error=extra -Wno-error=inline -Wno-error=logical-not-parentheses -Wno-error=strict-aliasing -Wno-error=uninitialized -Wno-error=unused-but-set-variable -Wno-error=unused-function -Wno-error=unused-value -Wno-error=nonnull-compare -Wno-error=shift-negative-value -Wno-error=tautological-compare -Wno-error=unused-const-variable -Wno-error=bool-operation -Wno-error=deprecated -Wno-error=expansion-to-defined -Wno-error=format-overflow -Wno-error=format-truncation -Wno-error=implicit-fallthrough -Wno-error=int-in-bool-context -Wno-error=memset-elt-size -Wno-error=noexcept-type -Wno-error=nonnull -Wno-error=pointer-compare -Wno-error=stringop-overflow -Wno-error=aggressive-loop-optimizations -Wno-error=cast-function-type -Wno-error=catch-value -Wno-error=multistatement-macros -Wno-error=restrict -Wno-error=sizeof-pointer-memaccess -Wno-error=stringop-truncation  -I/home/asomers/freebsd/base/head/tests -I/home/asomers/freebsd/base/head/sys/fs/fuse -I/home/asomers/freebsd/base/head/sbin/mount -I/scratch/tmp/asomers/obj/home/asomers/freebsd/base/head/riscv.riscv64/tmp/usr/include/private -std=c++14       -c /home/asomers/freebsd/base/head/tests/sys/fs/fusefs/mockfs.cc -o mockfs.o
  ... Some other warnings ...
  
  /scratch/tmp/asomers/obj/home/asomers/freebsd/base/head/riscv.riscv64/tmp/usr/include/c++/v1/functional:1774:36: error: placement new constructing an object of type '_Fun' {aka 'std::__1::__function::__func<ReturnImmediate(std::__1::function<void(const mockfs_buf_in&, mockfs_buf_out&)>)::<lambda(auto:5&, auto:6&)>, std::__1::allocator<ReturnImmediate(std::__1::function<void(const mockfs_buf_in&, mockfs_buf_out&)>)::<lambda(auto:5&, auto:6&)> >, void(const mockfs_buf_in&, std::__1::vector<std::__1::unique_ptr<mockfs_buf_out> >&)>'} and size '64' in a region of type 'std::__1::aligned_storage<24>::type' and size '32' [-Werror=placement-new=]
                       ::new ((void*)&__buf_) _Fun(_VSTD::move(__f), _Alloc(__af));


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65034/new/

https://reviews.llvm.org/D65034





More information about the libcxx-commits mailing list