Skip to content

One bug when compiling with GCC 16.1 #3858

Description

@ProjectsKoryHasWorkedOn

Describe the bug

GCC 16.1.0 reports a -Warray-bounds error

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

No errors

Current Behavior

In file included from /usr/local/include/c++/16.1.0/bits/stl_tempbuf.h:61, 
                 from /usr/local/include/c++/16.1.0/memory:68, 
                 from aws-sdk/src/aws-cpp-sdk-core/source/monitoring/MonitoringManager.cpp:6:
In function ‘void std::_Destroy(_Tp*) [with _Tp = mutex]’, 
    inlined from ‘static void std::allocator_traits<std::allocator<void> >::destroy(allocator_type&, _Up*) [with _Up = std::mutex]’ at /usr/local/include/c++/16.1.0/bits/alloc_traits.h:859:17, 
    inlined from ‘void std::_Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp>::_M_dispose() [with _Tp = std::mutex; _Alloc = std::allocator<void>; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ at /usr/local/include/c++/16.1.0/bits/shared_ptr_base.h:682:35, 
    inlined from ‘void std::_Sp_counted_base<_Lp>::_M_release() [with __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ at /usr/local/include/c++/16.1.0/bits/shared_ptr_base.h:423:18, 
    inlined from ‘void std::_Sp_counted_base<_Lp>::_M_release() [with __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ at /usr/local/include/c++/16.1.0/bits/shared_ptr_base.h:392:5, 
    inlined from ‘std::__shared_count<_Lp>::__shared_count() [with __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ at /usr/local/include/c++/16.1.0/bits/shared_ptr_base.h:1136:21, 
    inlined from ‘std::__shared_ptr<_Tp, _Lp>::__shared_ptr() [with _Tp = Aws::Monitoring::DefaultMonitoringFactory; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ at /usr/local/include/c++/16.1.0/bits/shared_ptr_base.h:1610:7, 
    inlined from ‘std::shared_ptr<Aws::Monitoring::DefaultMonitoringFactory>::shared_ptr()’ at /usr/local/include/c++/16.1.0/bits/shared_ptr.h:175:11, 
    inlined from ‘void Aws::Monitoring::InitMonitoring(const std::vector<std::function<std::unique_ptr<MonitoringFactory, Aws::Deleter<MonitoringFactory> >()> >&)’ at aws-sdk/src/aws-cpp-sdk-core/source/monitoring/MonitoringManager.cpp:138:9: 

/usr/local/include/c++/16.1.0/bits/stl_construct.h:166:7: error: array subscript ‘std::mutex[0]’ is partly outside array bounds of ‘unsigned char [24]’ [-Werror=array-bounds=] 
  166 | __pointer->_Tp(); 
      | ^~~~~~~~~ 

In file included from /usr/local/include/c++/16.1.0/x86_64-pc-linux-gnu/bits/c++allocator.h:33, 
                 from /usr/local/include/c++/16.1.0/bits/allocator.h:46, 
                 from /usr/local/include/c++/16.1.0/memory:67:
In member function ‘_Tp* std::__new_allocator<_Tp>::allocate(size_type, const void*) [with _Tp = std::_Sp_counted_ptr_inplace<Aws::Monitoring::DefaultMonitoringFactory, std::allocator<Aws::Monitoring::DefaultMonitoringFactory>, __gnu_cxx::_S_atomic>]’, 
    inlined from ‘static _Tp* std::allocator_traits<std::allocator<_Tp1> >::allocate(allocator_type&, size_type) [with _Tp = std::_Sp_counted_ptr_inplace<Aws::Monitoring::DefaultMonitoringFactory, std::allocator<Aws::Monitoring::DefaultMonitoringFactory>, __gnu_cxx::_S_atomic>]’ at /usr/local/include/c++/16.1.0/bits/alloc_traits.h:638:28, 
    inlined from ‘std::__allocated_ptr<_Alloc> std::__allocate_guarded(_Alloc&) [with _Alloc = allocator<_Sp_counted_ptr_inplace<Aws::Monitoring::DefaultMonitoringFactory, allocator<Aws::Monitoring::DefaultMonitoringFactory>, __gnu_cxx::_S_atomic> >]’ at /usr/local/include/c++/16.1.0/bits/allocated_ptr.h:103:69, 
    inlined from ‘std::__shared_count<_Lp>::__shared_count(_Tp*&, std::_Sp_alloc_shared_tag<_Alloc>, _Args&& ...) [with _Tp = Aws::Monitoring::DefaultMonitoringFactory; _Alloc = std::allocator<Aws::Monitoring::DefaultMonitoringFactory>; _Args = {}; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ at /usr/local/include/c++/16.1.0/bits/shared_ptr_base.h:1034:9, 
    inlined from ‘std::__shared_ptr<_Tp, _Lp>::__shared_ptr(std::_Sp_alloc_shared_tag<_Tp>, _Args&& ...) [with _Alloc = std::allocator<Aws::Monitoring::DefaultMonitoringFactory>; _Args = {}; _Tp = Aws::Monitoring::DefaultMonitoringFactory; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ at /usr/local/include/c++/16.1.0/bits/shared_ptr_base.h:1812:14, 
    inlined from ‘std::shared_ptr<_Tp>::shared_ptr(std::_Sp_alloc_shared_tag<_Tp>, _Args&& ...) [with _Alloc = std::allocator<Aws::Monitoring::DefaultMonitoringFactory>; _Args = {}; _Tp = Aws::Monitoring::DefaultMonitoringFactory]’ at /usr/local/include/c++/16.1.0/bits/shared_ptr.h:463:59, 
    inlined from ‘std::shared_ptr<typename std::enable_if<(! std::is_array<_Tp>::value), _Tp>::type> std::allocate_shared(const _Alloc&, _Args&& ...) [with _Tp = Aws::Monitoring::DefaultMonitoringFactory; _Alloc = allocator<Aws::Monitoring::DefaultMonitoringFactory>; _Args = {}]’ at /usr/local/include/c++/16.1.0/bits/shared_ptr.h:1049:39, 
    inlined from ‘std::shared_ptr<_Tp> Aws::MakeShared(const char*, ArgTypes&& ...) [with T = Monitoring::DefaultMonitoringFactory; ArgTypes = {}]’ at aws-sdk/src/aws-cpp-sdk-core/include/aws/core/utils/memory/stl/AWSAllocator.h:117:111, 
    inlined from ‘void Aws::Monitoring::InitMonitoring(const std::vector<std::function<std::unique_ptr<MonitoringFactory, Aws::Deleter<MonitoringFactory> >()> >&)’ at aws-sdk/src/aws-cpp-sdk-core/source/monitoring/MonitoringManager.cpp:138:9

Reproduction Steps

Compile AWS SDK with GCC 16.1

Possible Solution

Passing this flag -DCMAKE_CXX_FLAGS="-Wno-error=array-bounds allowed me to get past this warning / error with GCC 16.1 in meantime

AWS CPP SDK version used

1.11.839

Compiler and Version used

gcc (GCC) 16.1.0

Operating System and version

Ubuntu 24.04.3 LTS

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.needs-triageThis issue or PR still needs to be triaged.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions