https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122334

            Bug ID: 122334
           Summary: [16 Regression] libstdc++/nvptx vs. commit
                    r16-4000-g9ee937b2f92a930eb5407260a56e5fe0fa137e85
                    "Add --param max-devirt-targets"
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Keywords: build
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tschwinge at gcc dot gnu.org
                CC: hubicka at gcc dot gnu.org
  Target Milestone: ---
            Target: nvptx

Created attachment 62583
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=62583&action=edit
'cow-fs_dir.ii'

As of commit r16-4000-g9ee937b2f92a930eb5407260a56e5fe0fa137e85 "Add --param
max-devirt-targets", libstdc++/nvptx sees a new diagnostic (or, fatal build
error, with '--enable-werror').

It looks somewhat related to PR122197 "predictively devirtualization vs
middle-end warnings since r16-4000", but might also be a genuine issue, latent
so far, only exposed now in the GCC/libstdc++/nvptx configuration.

Just in case that someone would like to have a look, build a
'--target=nvptx-none' C++ front end, and with the attached 'cow-fs_dir.ii',
run:

    $ build-gcc/gcc/cc1plus -fpreprocessed cow-fs_dir.ii -quiet
-mfake-ptx-alloca -misa=sm_52 -g -O2 -Wall -Wextra -Wwrite-strings -Wcast-qual
-Wabi=19 -Werror -std=gnu++17 -fimplicit-templates -fno-exceptions -fno-rtti -o
cow-fs_dir.s

I've not yet attempted to understand the C++.

The original error that I saw:

    make[5]: Entering directory
'[...]/build-gcc/nvptx-none/libstdc++-v3/src/c++17'
    /bin/bash ../../libtool --tag CXX --tag disable-shared   --mode=compile
[...]/build-gcc/./gcc/xgcc -shared-libgcc -B[...]/build-gcc/./gcc -nostdinc++
-L[...]/build-gcc/nvptx-none/libstdc++-v3/src
-L[...]/build-gcc/nvptx-none/libstdc++-v3/src/.libs
-L[...]/build-gcc/nvptx-none/libstdc++-v3/libsupc++/.libs -nostdinc
-B[...]/build-gcc/nvptx-none/newlib/ -isystem
[...]/build-gcc/nvptx-none/newlib/targ-include -isystem
[...]/source-gcc/newlib/libc/include -B/nvptx-none/bin/ -B/nvptx-none/lib/
-isystem /nvptx-none/include -isystem /nvptx-none/sys-include
--sysroot=[...]/install/nvptx-none   -I[...]/source-gcc/libstdc++-v3/../libgcc
-I[...]/build-gcc/nvptx-none/libstdc++-v3/include/nvptx-none
-I[...]/build-gcc/nvptx-none/libstdc++-v3/include
-I[...]/source-gcc/libstdc++-v3/libsupc++   -std=gnu++17 -nostdinc++  
-fno-implicit-templates  -Wall -Wextra -Wwrite-strings -Wcast-qual -Wabi=19
-Werror -fdiagnostics-show-location=once  -mfake-ptx-alloca  
-frandom-seed=cow-fs_dir.lo  -fimplicit-templates -g -O2 -fno-exceptions
-fno-rtti  -c -o cow-fs_dir.lo
[...]/source-gcc/libstdc++-v3/src/c++17/cow-fs_dir.cc
    libtool: compile:  [...]/build-gcc/./gcc/xgcc -shared-libgcc
-B[...]/build-gcc/./gcc -nostdinc++
-L[...]/build-gcc/nvptx-none/libstdc++-v3/src
-L[...]/build-gcc/nvptx-none/libstdc++-v3/src/.libs
-L[...]/build-gcc/nvptx-none/libstdc++-v3/libsupc++/.libs -nostdinc
-B[...]/build-gcc/nvptx-none/newlib/ -isystem
[...]/build-gcc/nvptx-none/newlib/targ-include -isystem
[...]/source-gcc/newlib/libc/include -B/nvptx-none/bin/ -B/nvptx-none/lib/
-isystem /nvptx-none/include -isystem /nvptx-none/sys-include
--sysroot=[...]/install/nvptx-none -I[...]/source-gcc/libstdc++-v3/../libgcc
-I[...]/build-gcc/nvptx-none/libstdc++-v3/include/nvptx-none
-I[...]/build-gcc/nvptx-none/libstdc++-v3/include
-I[...]/source-gcc/libstdc++-v3/libsupc++ -std=gnu++17 -nostdinc++
-fno-implicit-templates -Wall -Wextra -Wwrite-strings -Wcast-qual -Wabi=19
-Werror -fdiagnostics-show-location=once -mfake-ptx-alloca
-frandom-seed=cow-fs_dir.lo -fimplicit-templates -g -O2 -fno-exceptions
-fno-rtti -c [...]/source-gcc/libstdc++-v3/src/c++17/cow-fs_dir.cc -o
cow-fs_dir.o
    In file included from
[...]/build-gcc/nvptx-none/libstdc++-v3/include/bits/shared_ptr.h:53,
                     from
[...]/build-gcc/nvptx-none/libstdc++-v3/include/bits/fs_path.h:46,
                     from
[...]/build-gcc/nvptx-none/libstdc++-v3/include/filesystem:54,
                     from [...]/source-gcc/libstdc++-v3/src/c++17/fs_dir.cc:30,
                     from
[...]/source-gcc/libstdc++-v3/src/c++17/cow-fs_dir.cc:26:
    In destructor ‘std::_Sp_counted_ptr_inplace<_Tp, _Alloc,
_Lp>::~_Sp_counted_ptr_inplace() [with _Tp =
std::filesystem::recursive_directory_iterator::_Dir_stack; _Alloc =
std::allocator<std::filesystem::recursive_directory_iterator::_Dir_stack>;
__gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_single]’,
        inlined from ‘std::_Sp_counted_ptr_inplace<_Tp, _Alloc,
_Lp>::~_Sp_counted_ptr_inplace() [with _Tp =
std::filesystem::recursive_directory_iterator::_Dir_stack; _Alloc =
std::allocator<std::filesystem::recursive_directory_iterator::_Dir_stack>;
__gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_single]’ at
[...]/build-gcc/nvptx-none/libstdc++-v3/include/bits/shared_ptr_base.h:670:45,
        inlined from ‘void std::_Sp_counted_base<_Lp>::_M_destroy() [with
__gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_single]’ at
[...]/build-gcc/nvptx-none/libstdc++-v3/include/bits/shared_ptr_base.h:143:9,
        inlined from ‘void std::_Sp_counted_base<_Lp>::_M_weak_release() [with
__gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_single]’ at
[...]/build-gcc/nvptx-none/libstdc++-v3/include/bits/shared_ptr_base.h:303:12,
        inlined from ‘void std::_Sp_counted_base<_Lp>::_M_weak_release() [with
__gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_single]’ at
[...]/build-gcc/nvptx-none/libstdc++-v3/include/bits/shared_ptr_base.h:300:5,
        inlined from ‘void std::_Sp_counted_base<_Lp>::_M_release() [with
__gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_single]’ at
[...]/build-gcc/nvptx-none/libstdc++-v3/include/bits/shared_ptr_base.h:374:19,
        inlined from ‘void std::_Sp_counted_base<_Lp>::_M_release() [with
__gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_single]’ at
[...]/build-gcc/nvptx-none/libstdc++-v3/include/bits/shared_ptr_base.h:369:5,
        inlined from ‘std::__shared_count<_Lp>::~__shared_count() [with
__gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_single]’ at
[...]/build-gcc/nvptx-none/libstdc++-v3/include/bits/shared_ptr_base.h:1129:21,
        inlined from ‘std::__shared_ptr<_Tp, _Lp>::~__shared_ptr() [with _Tp =
std::filesystem::_Dir; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_single]’ at
[...]/build-gcc/nvptx-none/libstdc++-v3/include/bits/shared_ptr_base.h:1603:7,
        inlined from
‘std::filesystem::directory_iterator::directory_iterator(const
std::filesystem::path&, std::filesystem::directory_options, std::error_code*)’
at [...]/source-gcc/libstdc++-v3/src/c++17/fs_dir.cc:222:5:
   
[...]/build-gcc/nvptx-none/libstdc++-v3/include/bits/shared_ptr_base.h:670:45:
error: array subscript
‘std::_Sp_counted_ptr_inplace<std::filesystem::recursive_directory_iterator::_Dir_stack,
std::allocator<std::filesystem::recursive_directory_iterator::_Dir_stack>,
__gnu_cxx::_S_single>[0]’ is partly outside array bounds of ‘unsigned char
[64]’ [-Werror=array-bounds=]
      670 |       ~_Sp_counted_ptr_inplace() noexcept { }
          |                                             ^
    In file included from
[...]/build-gcc/nvptx-none/libstdc++-v3/include/nvptx-none/bits/c++allocator.h:33,
                     from
[...]/build-gcc/nvptx-none/libstdc++-v3/include/bits/allocator.h:46,
                     from
[...]/build-gcc/nvptx-none/libstdc++-v3/include/string:45,
                     from
[...]/build-gcc/nvptx-none/libstdc++-v3/include/stdexcept:41,
                     from
[...]/build-gcc/nvptx-none/libstdc++-v3/include/system_error:45,
                     from
[...]/build-gcc/nvptx-none/libstdc++-v3/include/bits/fs_fwd.h:35,
                     from
[...]/build-gcc/nvptx-none/libstdc++-v3/include/filesystem:53:
    In member function ‘_Tp* std::__new_allocator<_Tp>::allocate(size_type,
const void*) [with _Tp = std::_Sp_counted_ptr_inplace<std::filesystem::_Dir,
std::allocator<std::filesystem::_Dir>, __gnu_cxx::_S_single>]’,
        inlined from ‘static _Tp* std::allocator_traits<std::allocator<_CharT>
>::allocate(allocator_type&, size_type) [with _Tp =
std::_Sp_counted_ptr_inplace<std::filesystem::_Dir,
std::allocator<std::filesystem::_Dir>, __gnu_cxx::_S_single>]’ at
[...]/build-gcc/nvptx-none/libstdc++-v3/include/bits/alloc_traits.h:614:28,
        inlined from ‘std::__allocated_ptr<_Alloc>
std::__allocate_guarded(_Alloc&) [with _Alloc =
allocator<_Sp_counted_ptr_inplace<filesystem::_Dir,
allocator<filesystem::_Dir>, __gnu_cxx::_S_single> >]’ at
[...]/build-gcc/nvptx-none/libstdc++-v3/include/bits/allocated_ptr.h:103:69,
        inlined from ‘std::__shared_count<_Lp>::__shared_count(_Tp*&,
std::_Sp_alloc_shared_tag<_Alloc>, _Args&& ...) [with _Tp =
std::filesystem::_Dir; _Alloc = std::allocator<std::filesystem::_Dir>; _Args =
{std::filesystem::_Dir}; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_single]’
at
[...]/build-gcc/nvptx-none/libstdc++-v3/include/bits/shared_ptr_base.h:1027:9,
        inlined from ‘std::__shared_ptr<_Tp,
_Lp>::__shared_ptr(std::_Sp_alloc_shared_tag<_Tp>, _Args&& ...) [with _Alloc =
std::allocator<std::filesystem::_Dir>; _Args = {std::filesystem::_Dir}; _Tp =
std::filesystem::_Dir; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_single]’ at
[...]/build-gcc/nvptx-none/libstdc++-v3/include/bits/shared_ptr_base.h:1805:14,
        inlined from ‘std::__shared_ptr<_Tp, _Lp> std::__allocate_shared(const
_Alloc&, _Args&& ...) [with _Tp = filesystem::_Dir; __gnu_cxx::_Lock_policy _Lp
= __gnu_cxx::_S_single; _Alloc = allocator<filesystem::_Dir>; _Args =
{filesystem::_Dir}]’ at
[...]/build-gcc/nvptx-none/libstdc++-v3/include/bits/shared_ptr_base.h:2378:39,
        inlined from ‘std::__shared_ptr<_Tp, _Lp> std::__make_shared(_Args&&
...) [with _Tp = filesystem::_Dir; __gnu_cxx::_Lock_policy _Lp =
__gnu_cxx::_S_single; _Args = {filesystem::_Dir}]’ at
[...]/build-gcc/nvptx-none/libstdc++-v3/include/bits/shared_ptr_base.h:2388:42,
        inlined from
‘std::filesystem::directory_iterator::directory_iterator(const
std::filesystem::path&, std::filesystem::directory_options, std::error_code*)’
at [...]/source-gcc/libstdc++-v3/src/c++17/fs_dir.cc:219:60:
   
[...]/build-gcc/nvptx-none/libstdc++-v3/include/bits/new_allocator.h:151:73:
note: object of size 64 allocated by ‘operator new’
      151 |         return static_cast<_Tp*>(_GLIBCXX_OPERATOR_NEW(__n *
sizeof(_Tp)));
          |                                                                    
    ^
    In destructor ‘std::_Sp_counted_ptr_inplace<_Tp, _Alloc,
_Lp>::~_Sp_counted_ptr_inplace() [with _Tp =
std::filesystem::recursive_directory_iterator::_Dir_stack; _Alloc =
std::allocator<std::filesystem::recursive_directory_iterator::_Dir_stack>;
__gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_single]’,
        inlined from ‘void std::_Sp_counted_ptr_inplace<_Tp, _Alloc,
_Lp>::_M_destroy() [with _Tp =
std::filesystem::recursive_directory_iterator::_Dir_stack; _Alloc =
std::allocator<std::filesystem::recursive_directory_iterator::_Dir_stack>;
__gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_single]’ at
[...]/build-gcc/nvptx-none/libstdc++-v3/include/bits/shared_ptr_base.h:684:32,
        inlined from ‘void std::_Sp_counted_base<_Lp>::_M_weak_release() [with
__gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_single]’ at
[...]/build-gcc/nvptx-none/libstdc++-v3/include/bits/shared_ptr_base.h:303:12,
        inlined from ‘void std::_Sp_counted_base<_Lp>::_M_weak_release() [with
__gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_single]’ at
[...]/build-gcc/nvptx-none/libstdc++-v3/include/bits/shared_ptr_base.h:300:5,
        inlined from ‘void std::_Sp_counted_base<_Lp>::_M_release() [with
__gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_single]’ at
[...]/build-gcc/nvptx-none/libstdc++-v3/include/bits/shared_ptr_base.h:374:19,
        inlined from ‘void std::_Sp_counted_base<_Lp>::_M_release() [with
__gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_single]’ at
[...]/build-gcc/nvptx-none/libstdc++-v3/include/bits/shared_ptr_base.h:369:5,
        inlined from ‘std::__shared_count<_Lp>::~__shared_count() [with
__gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_single]’ at
[...]/build-gcc/nvptx-none/libstdc++-v3/include/bits/shared_ptr_base.h:1129:21,
        inlined from ‘std::__shared_ptr<_Tp, _Lp>::~__shared_ptr() [with _Tp =
std::filesystem::_Dir; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_single]’ at
[...]/build-gcc/nvptx-none/libstdc++-v3/include/bits/shared_ptr_base.h:1603:7,
        inlined from
‘std::filesystem::directory_iterator::directory_iterator(const
std::filesystem::path&, std::filesystem::directory_options, std::error_code*)’
at [...]/source-gcc/libstdc++-v3/src/c++17/fs_dir.cc:222:5:
   
[...]/build-gcc/nvptx-none/libstdc++-v3/include/bits/shared_ptr_base.h:670:45:
error: array subscript
‘std::_Sp_counted_ptr_inplace<std::filesystem::recursive_directory_iterator::_Dir_stack,
std::allocator<std::filesystem::recursive_directory_iterator::_Dir_stack>,
__gnu_cxx::_S_single>[0]’ is partly outside array bounds of ‘unsigned char
[64]’ [-Werror=array-bounds=]
      670 |       ~_Sp_counted_ptr_inplace() noexcept { }
          |                                             ^
    In member function ‘_Tp* std::__new_allocator<_Tp>::allocate(size_type,
const void*) [with _Tp = std::_Sp_counted_ptr_inplace<std::filesystem::_Dir,
std::allocator<std::filesystem::_Dir>, __gnu_cxx::_S_single>]’,
        inlined from ‘static _Tp* std::allocator_traits<std::allocator<_CharT>
>::allocate(allocator_type&, size_type) [with _Tp =
std::_Sp_counted_ptr_inplace<std::filesystem::_Dir,
std::allocator<std::filesystem::_Dir>, __gnu_cxx::_S_single>]’ at
[...]/build-gcc/nvptx-none/libstdc++-v3/include/bits/alloc_traits.h:614:28,
        inlined from ‘std::__allocated_ptr<_Alloc>
std::__allocate_guarded(_Alloc&) [with _Alloc =
allocator<_Sp_counted_ptr_inplace<filesystem::_Dir,
allocator<filesystem::_Dir>, __gnu_cxx::_S_single> >]’ at
[...]/build-gcc/nvptx-none/libstdc++-v3/include/bits/allocated_ptr.h:103:69,
        inlined from ‘std::__shared_count<_Lp>::__shared_count(_Tp*&,
std::_Sp_alloc_shared_tag<_Alloc>, _Args&& ...) [with _Tp =
std::filesystem::_Dir; _Alloc = std::allocator<std::filesystem::_Dir>; _Args =
{std::filesystem::_Dir}; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_single]’
at
[...]/build-gcc/nvptx-none/libstdc++-v3/include/bits/shared_ptr_base.h:1027:9,
        inlined from ‘std::__shared_ptr<_Tp,
_Lp>::__shared_ptr(std::_Sp_alloc_shared_tag<_Tp>, _Args&& ...) [with _Alloc =
std::allocator<std::filesystem::_Dir>; _Args = {std::filesystem::_Dir}; _Tp =
std::filesystem::_Dir; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_single]’ at
[...]/build-gcc/nvptx-none/libstdc++-v3/include/bits/shared_ptr_base.h:1805:14,
        inlined from ‘std::__shared_ptr<_Tp, _Lp> std::__allocate_shared(const
_Alloc&, _Args&& ...) [with _Tp = filesystem::_Dir; __gnu_cxx::_Lock_policy _Lp
= __gnu_cxx::_S_single; _Alloc = allocator<filesystem::_Dir>; _Args =
{filesystem::_Dir}]’ at
[...]/build-gcc/nvptx-none/libstdc++-v3/include/bits/shared_ptr_base.h:2378:39,
        inlined from ‘std::__shared_ptr<_Tp, _Lp> std::__make_shared(_Args&&
...) [with _Tp = filesystem::_Dir; __gnu_cxx::_Lock_policy _Lp =
__gnu_cxx::_S_single; _Args = {filesystem::_Dir}]’ at
[...]/build-gcc/nvptx-none/libstdc++-v3/include/bits/shared_ptr_base.h:2388:42,
        inlined from
‘std::filesystem::directory_iterator::directory_iterator(const
std::filesystem::path&, std::filesystem::directory_options, std::error_code*)’
at [...]/source-gcc/libstdc++-v3/src/c++17/fs_dir.cc:219:60:
   
[...]/build-gcc/nvptx-none/libstdc++-v3/include/bits/new_allocator.h:151:73:
note: object of size 64 allocated by ‘operator new’
      151 |         return static_cast<_Tp*>(_GLIBCXX_OPERATOR_NEW(__n *
sizeof(_Tp)));
          |                                                                    
    ^
    cc1plus: all warnings being treated as errors
    make[5]: *** [Makefile:590: cow-fs_dir.lo] Error 1
    make[5]: Target 'all' not remade because of errors.
    make[5]: Leaving directory
'[...]/build-gcc/nvptx-none/libstdc++-v3/src/c++17'

Reply via email to