Skip to content

compile error with gcc7.3 and -std=c++17 #20370

Open
@mayuehit

Description

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

What operating system (Linux, Windows, ...) and version?
Linux
What runtime / compiler are you using (e.g., python version or gcc version)
gcc (GCC) 7.3.0
bazel 6.5.0
build --action_env=BAZEL_CXXOPTS=-std=c++17
What did you do?
Steps to reproduce the behavior:

  1. compile protobuf with gcc7.3 and -std=c++17

What did you expect to see
compile success
What did you see instead?

external/com_google_protobuf/src/google/protobuf/compiler/BUILD.bazel:130:11: Compiling src/google/protobuf/compiler/main.cc [for tool] failed: (Exit 1): gcc failed: error executing command (from target @com_google_protobuf//src/google/protobuf/compiler:protoc_lib)

(cd /home/euler9/build/output/sandbox/linux-sandbox/3533/execroot/my_project && \
  exec env - \
    LD_LIBRARY_PATH=/usr/local/gcc-7.3.0/lib:/usr/local/gcc-7.3.0/lib64:/usr/lib:/opt/buildtools/python3.9/lib:/opt/buildtools/python3.9/lib:/usr/local/gcc-7.3.0/lib:/usr/local/gcc-7.3.0/lib64: \
    PATH=/opt/buildtools/secBepkit-2.1.T2:/opt/buildtools/secBepkit-2.1.T2:/opt/buildtools/artget-1.3.7.3:/opt/buildtools/node.js-v18.20.1/bin/bin:/usr/local/gcc-7.3.0/bin:/opt/buildtools/python3.9/bin:/opt/buildtools/google_protobuf-3.13.0/bin:/opt/buildtools/golang_go-1.22.1/bin:/opt/buildtools/go_workspace/bin:/opt/buildtools/apache_maven-3.8.8/bin:/opt/buildtools/adoptopenjdk_openjdk8-binaries-jdk8u412-b08/bin:/opt/buildtools/adoptopenjdk_openjdk8-binaries-jdk8u412-b08/jre/bin:/opt/buildtools/python3.9/bin:/usr/local/gcc-7.3.0/bin:/opt/buildtools/golang_go-1.22.1/bin:/opt/buildtools/go_workspace/bin:/opt/buildtools/adoptopenjdk_openjdk8-binaries-jdk8u412-b08/bin:/opt/buildtools/adoptopenjdk_openjdk8-binaries-jdk8u412-b08/jre/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
    PWD=/proc/self/cwd \
  /usr/local/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections -fdata-sections '-std=c++17' -MD -MF bazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/_objs/protoc_lib/main.d '-frandom-seed=bazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/_objs/protoc_lib/main.o' '-DBAZEL_CURRENT_REPOSITORY="com_google_protobuf"' -iquote external/com_google_protobuf -iquote bazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf -iquote external/com_google_absl -iquote bazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_absl -iquote external/utf8_range -iquote bazel-out/k8-opt-exec-2B5CBBC6/bin/external/utf8_range -iquote external/zlib -iquote bazel-out/k8-opt-exec-2B5CBBC6/bin/external/zlib -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/_virtual_includes/code_generator -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/protobuf_nowkt -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/protobuf_lite -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/arena -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/arena_align -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/stubs/_virtual_includes/lite -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/port_def -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/arena_allocation_policy -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/arena_cleanup -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/string_block -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/internal_visibility -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/varint_shuffle -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/io/_virtual_includes/io -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/io/_virtual_includes/io_win32 -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/io/_virtual_includes/gzip_stream -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/stubs/_virtual_includes/stubs -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/io/_virtual_includes/printer -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/io/_virtual_includes/zero_copy_sink -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/io/_virtual_includes/tokenizer -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/_virtual_includes/retention -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/_virtual_includes/command_line_interface -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/_virtual_includes/importer -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/descriptor_legacy -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/allowlists/_virtual_includes/allowlists -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/allowlists/_virtual_includes/allowlist -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/cpp/_virtual_includes/cpp -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/cpp/_virtual_includes/names -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/cpp/_virtual_includes/names_internal -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/_virtual_includes/versions -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/csharp/_virtual_includes/csharp -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/csharp/_virtual_includes/names -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/java/_virtual_includes/java -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/java/_virtual_includes/names -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/java/_virtual_includes/names_internal -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/objectivec/_virtual_includes/objectivec -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/objectivec/_virtual_includes/line_consumer -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/objectivec/_virtual_includes/names -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/objectivec/_virtual_includes/names_internal -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/php/_virtual_includes/php -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/php/_virtual_includes/names -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/python/_virtual_includes/python -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/ruby/_virtual_includes/ruby -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/rust/_virtual_includes/rust -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/rust/_virtual_includes/context -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/rust/_virtual_includes/message -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/rust/_virtual_includes/accessors -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/rust/_virtual_includes/naming -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/rust/_virtual_includes/oneof -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/rust/_virtual_includes/relative_path -isystem external/zlib/zlib/include -isystem bazel-out/k8-opt-exec-2B5CBBC6/bin/external/zlib/zlib/include -g0 -g0 -DHAVE_ZLIB -Woverloaded-virtual -Wno-sign-compare -Wno-nonnull -Werror -fno-canonical-system-headers -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c external/com_google_protobuf/src/google/protobuf/compiler/main.cc -o bazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/_objs/protoc_lib/main.o)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
In file included from bazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/protobuf_nowkt/google/protobuf/descriptor.h:53:0,
                 from bazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/protobuf_nowkt/google/protobuf/generated_message_reflection.h:24,
                 from bazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/protobuf_nowkt/google/protobuf/descriptor.pb.h:32,
                 from bazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/_virtual_includes/command_line_interface/google/protobuf/compiler/command_line_interface.h:29,
                 from external/com_google_protobuf/src/google/protobuf/compiler/main.cc:9:
bazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/protobuf_lite/google/protobuf/extension_set.h: In constructor 'constexpr google::protobuf::internal::ExtensionSet::ExtensionSet()':
bazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/protobuf_lite/google/protobuf/extension_set.h:169:53: error: temporary of non-literal type 'google::protobuf::internal::ExtensionSet' in a constant expression
   constexpr ExtensionSet() : ExtensionSet(nullptr) {}
                                                     ^
bazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/protobuf_lite/google/protobuf/extension_set.h:167:23: note: 'google::protobuf::internal::ExtensionSet' is not literal because:
 class PROTOBUF_EXPORT ExtensionSet {
                       ^~~~~~~~~~~~
bazel-out/k8-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/protobuf_lite/google/protobuf/extension_set.h:167:23: note:   'google::protobuf::internal::ExtensionSet' has a non-trivial destructor

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

Anything else we should know about your project / environment

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions