protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

Compile warning C++ - Ubuntu

Open mohsenomidi opened this issue 6 years ago • 4 comments
trafficstars

What version of protobuf and what language are you using? Version: master Language: C++

What operating system (Linux, Windows, ...) and version? Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-54-generic x86_64)

What runtime / compiler are you using (e.g., python version or gcc version) gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)

What did you do? by compilation manual start compiling the project

What did you expect to see Successful compilation

What did you see instead? Compile Warning

Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).

CXX google/protobuf/implicit_weak_message.lo CXX google/protobuf/message_lite.lo In file included from /usr/include/string.h:494:0, from ./google/protobuf/stubs/port.h:38, from ./google/protobuf/stubs/common.h:46, from ./google/protobuf/message_lite.h:45, from google/protobuf/message_lite.cc:36: In function ‘void* memcpy(void*, const void*, size_t)’, inlined from ‘google::protobuf::uint8* google::protobuf::io::EpsCopyOutputStream::WriteRaw(const void*, int, google::protobuf::uint8*)’ at ./google/protobuf/io/coded_stream.h:697:16, inlined from ‘virtual google::protobuf::uint8* google::protobuf::internal::ImplicitWeakMessage::InternalSerializeWithCachedSizesToArray(google::protobuf::uint8*, google::protobuf::io::EpsCopyOutputStream*) const’ at ./google/protobuf/implicit_weak_message.h:92:35, inlined from ‘bool google::protobuf::MessageLite::SerializePartialToZeroCopyStream(google::protobuf::io::ZeroCopyOutputStream*) const’ at google/protobuf/message_lite.cc:423:51: /usr/include/x86_64-linux-gnu/bits/string_fortified.h:34:71: warning: ‘void* __builtin___memcpy_chk(void*, const void*, long unsigned int, long unsigned int)’: specified size between 18446744071562067968 and 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=] return __builtin___memcpy_chk (__dest, __src, __len, __bos0 (__dest)); ^ CXXLD libprotobuf-lite.la ar: u' modifier ignored since D' is the default (see `U')

CXXLD libprotobuf.la ar: u' modifier ignored since D' is the default (see `U')

Anything else we should know about your project / environment nothing special

mohsenomidi avatar Jul 20 '19 11:07 mohsenomidi

Also in make check i have a warning :

CXXLD protobuf-test google/protobuf/testing/protobuf_test-googletest.o: In function google::protobuf::(anonymous namespace)::GetTemporaryDirectoryName()': /home/admin/tests/proto/protobuf/src/google/protobuf/testing/googletest.cc:124: warning: the use of tmpnam' is dangerous, better use `mkstemp' CXX google/protobuf/compiler/cpp/protobuf_lazy_descriptor_test-cpp_unittest.o

mohsenomidi avatar Jul 20 '19 11:07 mohsenomidi

Any news on this? I see the https://github.com/protocolbuffers/protobuf/pull/6617 has been closed without pushing the change.

ao2 avatar Mar 10 '22 17:03 ao2

Note about reproduction steps: It is necessary to use at least -O2 optimization mode (-O0 or -O1 is not enough) to see this warning.

Arfrever avatar Mar 10 '22 19:03 Arfrever

Still happens with gcc v12.1.0/protobuf v21.4. The entire versioning scheme had changes, yet this warning is still with us. :-)

From Compiling src/google/protobuf/message_lite.cc: In file included from /usr/include/string.h:535, from external/com_google_protobuf/src/google/protobuf/stubs/port.h:39, from external/com_google_protobuf/src/google/protobuf/stubs/common.h:48, from external/com_google_protobuf/src/google/protobuf/message_lite.h:46, from external/com_google_protobuf/src/google/protobuf/message_lite.cc:36: In function 'void* memcpy(void*, const void*, size_t)', inlined from 'uint8_t* google::protobuf::io::EpsCopyOutputStream::WriteRaw(const void*, int, uint8_t*)' at external/com_google_protobuf/src/google/protobuf/io/coded_stream.h:684:16, inlined from 'virtual uint8_t* google::protobuf::internal::ImplicitWeakMessage::_InternalSerialize(uint8_t*, google::protobuf::io::EpsCopyOutputStream*) const' at external/com_google_protobuf/src/google/protobuf/implicit_weak_message.h:103:28, inlined from 'bool google::protobuf::MessageLite::SerializePartialToZeroCopyStream(google::protobuf::io::ZeroCopyOutputStream*) const' at external/com_google_protobuf/src/google/protobuf/message_lite.cc:411:30: /usr/include/bits/string_fortified.h:29:33: warning: 'void* __builtin___memcpy_chk(void*, const void*, long unsigned int, long unsigned int)' specified size between 18446744071562067968 and 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=] 29 | return __builtin___memcpy_chk (__dest, __src, __len, | ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ 30 | __glibc_objsize0 (__dest)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~

oakad avatar Aug 04 '22 15:08 oakad

This was fixed by https://github.com/protocolbuffers/protobuf/commit/887daf693fa17d7baf7b55b278132a7115beae30#diff-d0961d63325c9a3f30b4769cf5d53d663bcb10d545c1125e4e7ebbd80182a992R683.

benjaminp avatar Jan 12 '23 18:01 benjaminp

I am still able to reproduce it with: protobuf 3.23.3 @System gcc 12.2.0 @System

do we know if there is a compatible version which fixes above issue ? @benjaminp @acozzette @haberman

Sanrahul02 avatar Jan 16 '24 23:01 Sanrahul02

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.

This issue is labeled inactive because the last activity was over 90 days ago.

github-actions[bot] avatar Apr 16 '24 10:04 github-actions[bot]