Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 716986 - dev-libs/protobuf: bug compiling protobuf generated c++ with -O3 optimization
Summary: dev-libs/protobuf: bug compiling protobuf generated c++ with -O3 optimization
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Arfrever Frehtes Taifersar Arahesis
Depends on:
Reported: 2020-04-10 20:43 UTC by David Flogeras
Modified: 2020-06-16 11:14 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---

protobuf file for minimal regression test (test.proto,69 bytes, text/plain)
2020-04-10 20:44 UTC, David Flogeras

Note You need to log in before you can comment on or make changes to this bug.
Description David Flogeras 2020-04-10 20:43:48 UTC
I just caught this in a regression test of my own.  I boiled it down to a minimal test that can be reproduced following these steps:

1. install gentoo/releases/amd64/autobuilds/current-stage3-amd64-uclibc-vanilla/

You can either run in a real system, or just chroot in

2. emerge protobuf

3. generate the protobuf code with the following command (I'll attach the minimal .proto file needed for this).

   protoc test.proto --cpp_out=./

4. compile the resulting code with the following

   g++ -O3 -c -Wall

It should spew out the following warnin, which is did not do as early as a few months ago (either gcc 9 or uclibc-ng 1.0.30+).  Other libc's don't see this behaviour for me.  I can reproduce it on armv6j-unknown-linux-uclibceabihf- as well.

In member function 'void mymsg::SharedCtor()',
    inlined from 'mymsg::mymsg()' at,
    inlined from 'void InitDefaultsscc_info_mymsg_test_2eproto()' at warning: 'void* memset(void*, int, size_t)' offset [29, 32] from the object at '_mymsg_default_instance_' is out of the bounds of referenced subobject 'mymsg::a_' with type 'unsigned int' at offset 24 [-Warray-bounds]
  111 |   ::memset(&a_, 0, static_cast<size_t>(
      |   ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  112 |       reinterpret_cast<char*>(&b_) -
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  113 |       reinterpret_cast<char*>(&a_)) + sizeof(b_));

Reproducible: Always
Comment 1 David Flogeras 2020-04-10 20:44:45 UTC
Created attachment 632026 [details]
protobuf file for minimal regression test
Comment 2 David Flogeras 2020-04-10 20:46:42 UTC
It should spew out the following warning, which it did not....

Sorry, just learning to type.
Comment 3 David Flogeras 2020-06-06 12:48:08 UTC
Actually this appears to also affect non uclibc-ng, it just was the first environment I hit it with.  Looks like it's a new warning picked up by gcc9.  Here's a github bug for protobuf.

Should I close this, or wait until upstream maybe addresses it?  Either way I don't think it's embedded/blueness problem.
Comment 4 Anthony Basile gentoo-dev 2020-06-16 11:14:53 UTC
Reassigning to the maintainers of protobuf