Skip to content

build warning with gcc 12 #54736

Description

@richardlau

We recently switched to build with gcc 12 on RHEL (other platforms to follow) in nodejs/build#3886.
This is causing ubi81_sharedlibs_openssl111fips_x64 to fail as it builds with --error-on-warn.

e.g. https://ci.nodejs.org/job/node-test-commit-linux-containered/45894/nodes=ubi81_sharedlibs_openssl111fips_x64/

07:14:38 In file included from /opt/rh/gcc-toolset-12/root/usr/include/c++/12/string:40,
07:14:38                  from /opt/rh/gcc-toolset-12/root/usr/include/c++/12/bits/locale_classes.h:40,
07:14:38                  from /opt/rh/gcc-toolset-12/root/usr/include/c++/12/locale:39,
07:14:38                  from ../src/util-inl.h:29,
07:14:38                  from ../src/node_dotenv.h:6,
07:14:38                  from ../src/node_dotenv.cc:1:
07:14:38 In static member function 'static constexpr std::char_traits<char>::char_type* std::char_traits<char>::copy(char_type*, const char_type*, std::size_t)',
07:14:38     inlined from 'static constexpr void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_S_copy(_CharT*, const _CharT*, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' at /opt/rh/gcc-toolset-12/root/usr/include/c++/12/bits/basic_string.h:423:21,
07:14:38     inlined from 'constexpr std::__cxx11::basic_string<_CharT, _Traits, _Allocator>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_replace(size_type, size_type, const _CharT*, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' at /opt/rh/gcc-toolset-12/root/usr/include/c++/12/bits/basic_string.tcc:532:22,
07:14:38     inlined from 'constexpr std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type, size_type, const _CharT*, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' at /opt/rh/gcc-toolset-12/root/usr/include/c++/12/bits/basic_string.h:2171:19,
07:14:38     inlined from 'constexpr std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type, size_type, const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' at /opt/rh/gcc-toolset-12/root/usr/include/c++/12/bits/basic_string.h:2196:22,
07:14:38     inlined from 'void node::Dotenv::ParseContent(std::string_view)' at ../src/node_dotenv.cc:164:35:
07:14:38 /opt/rh/gcc-toolset-12/root/usr/include/c++/12/bits/char_traits.h:431:56: error: 'void* __builtin_memcpy(void*, const void*, long unsigned int)' accessing 9223372036854775810 or more bytes at offsets [2, 9223372036854775807] and 1 may overlap up to 9223372036854775813 bytes at offset -3 [-Werror=restrict]
07:14:38   431 |         return static_cast<char_type*>(__builtin_memcpy(__s1, __s2, __n));
07:14:38       |                                        ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
07:14:38 cc1plus: all warnings being treated as errors
07:14:38 make[2]: *** [libnode.target.mk:445: /home/iojs/build/workspace/node-test-commit-linux-containered/out/Release/obj.target/libnode/src/node_dotenv.o] Error 1

Activity

  1. richardlau commented on Sep 3, 2024

    @richardlau
    MemberAuthor

    If we look at a rhel8-x64 build (where we haven't enabled --error-on-warn) we can see several instances of this warning being emitted, e.g. https://ci.nodejs.org/job/node-test-commit-linux/nodes=rhel8-x64/60200/consoleFull.

  2. richardlau commented on Sep 3, 2024

    @richardlau
    MemberAuthor
  3. added
    buildIssues and PRs related to Node.js builds or CI infrastructure.
    on Sep 3, 2024
  4. richardlau commented on Sep 3, 2024

    @richardlau
    MemberAuthor

    Other examples
    https://ci.nodejs.org/job/node-test-commit-linux/nodes=rhel8-x64/60200/consoleFull

    15:21:13     inlined from ‘void node::Dotenv::ParseContent(std::string_view)’ at ../src/node_dotenv.cc:164:35:
    15:21:13 /opt/rh/gcc-toolset-12/root/usr/include/c++/12/bits/char_traits.h:431:56: warning: ‘void* __builtin_memcpy(void*, const void*, long unsigned int)’ accessing 9223372036854775810 or more bytes at offsets [2, 9223372036854775807] and 1 may overlap up to 9223372036854775813 bytes at offset -3 [-Wrestrict]
    15:21:13   431 |         return static_cast<char_type*>(__builtin_memcpy(__s1, __s2, __n));
    15:21:13       |                                        ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
    
    15:21:16     inlined from ‘virtual std::string node::SocketAddressBlockList::SocketAddressMaskRule::ToString()’ at ../src/node_sockaddr.cc:500:14:
    15:21:16 /opt/rh/gcc-toolset-12/root/usr/include/c++/12/bits/char_traits.h:431:56: warning: ‘void* __builtin_memcpy(void*, const void*, long unsigned int)’ accessing 9223372036854775810 or more bytes at offsets [2, 9223372036854775807] and 1 may overlap up to 9223372036854775813 bytes at offset -3 [-Wrestrict]
    15:21:16   431 |         return static_cast<char_type*>(__builtin_memcpy(__s1, __s2, __n));
    15:21:16       |                                        ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
    
    15:21:16     inlined from ‘node::task_runner::ProcessRunner::ProcessRunner(std::shared_ptr<node::InitializationResultImpl>, const std::filesystem::__cxx11::path&, std::string_view, std::string_view, std::string_view, const node::task_runner::PositionalArgs&)’ at ../src/node_task_runner.cc:58:26:
    15:21:16 /opt/rh/gcc-toolset-12/root/usr/include/c++/12/bits/char_traits.h:431:56: warning: ‘void* __builtin_memcpy(void*, const void*, long unsigned int)’ accessing 9223372036854775810 or more bytes at offsets [2, 9223372036854775807] and 1 may overlap up to 9223372036854775813 bytes at offset -3 [-Wrestrict]
    15:21:16   431 |         return static_cast<char_type*>(__builtin_memcpy(__s1, __s2, __n));
    15:21:16       |                                        ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
    
    15:21:16     inlined from ‘static void node::url::BindingData::Format(const v8::FunctionCallbackInfo<v8::Value>&)’ at ../src/node_url.cc:228:38:
    15:21:16 /opt/rh/gcc-toolset-12/root/usr/include/c++/12/bits/char_traits.h:431:56: warning: ‘void* __builtin_memcpy(void*, const void*, long unsigned int)’ accessing 9223372036854775810 or more bytes at offsets [2, 9223372036854775807] and 1 may overlap up to 9223372036854775813 bytes at offset -3 [-Wrestrict]
    15:21:16   431 |         return static_cast<char_type*>(__builtin_memcpy(__s1, __s2, __n));
    15:21:16       |                                        ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
    
    15:21:20     inlined from ‘void node::crypto::LogSecret(const SSLPointer&, const char*, const unsigned char*, std::size_t)’ at ../src/crypto/crypto_common.cc:61:15:
    15:21:20 /opt/rh/gcc-toolset-12/root/usr/include/c++/12/bits/char_traits.h:431:56: warning: ‘void* __builtin_memcpy(void*, const void*, long unsigned int)’ accessing 9223372036854775810 or more bytes at offsets [2, 9223372036854775807] and 1 may overlap up to 9223372036854775813 bytes at offset -3 [-Wrestrict]
    15:21:20   431 |         return static_cast<char_type*>(__builtin_memcpy(__s1, __s2, __n));
    15:21:20       |                                        ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
    
    15:21:20     inlined from ‘void node::crypto::LogSecret(const SSLPointer&, const char*, const unsigned char*, std::size_t)’ at ../src/crypto/crypto_common.cc:64:11:
    15:21:20 /opt/rh/gcc-toolset-12/root/usr/include/c++/12/bits/char_traits.h:431:56: warning: ‘void* __builtin_memcpy(void*, const void*, long unsigned int)’ accessing 9223372036854775810 or more bytes at offsets [2, 9223372036854775807] and 1 may overlap up to 9223372036854775813 bytes at offset -3 [-Wrestrict]
    15:21:20   431 |         return static_cast<char_type*>(__builtin_memcpy(__s1, __s2, __n));
    15:21:20       |                                        ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
    
  5. richardlau commented on Sep 3, 2024

    @richardlau
    MemberAuthor

    I've opened #54737 to turn off -Wrestrict (i.e. -Wno-restrict).

  6. added a commit that references this issue on Sep 4, 2024
  7. added a commit that references this issue on Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buildIssues and PRs related to Node.js builds or CI infrastructure.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions