public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/110055] New: Dangling pointer warning inside std::vector on RISC-V
@ 2023-05-31 10:03 spriteovo at gmail dot com
  2023-05-31 10:05 ` [Bug c++/110055] " spriteovo at gmail dot com
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: spriteovo at gmail dot com @ 2023-05-31 10:03 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110055
           Summary: Dangling pointer warning inside std::vector on RISC-V
           Product: gcc
           Version: 13.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: spriteovo at gmail dot com
  Target Milestone: ---

This bug can only be reproduce on RISC-V platform.

Minimum reproducible example:

```cpp
#include <cstdint>
#include <vector>

struct Data {
  std::vector<uint16_t> v = {1, 1};
};

int main() {
  Data a;
  Data b;
}
```

Compile with `g++ main.cpp -Werror -Wall -fno-exceptions -O3`

Error message:

```
In file included from /usr/include/c++/13.1.1/vector:62,
                 from main.cpp:2:
In static member function ‘static _Up* std::__copy_move<_IsMove, true,
std::random_access_iterator_tag>::__copy_m(_Tp*, _Tp*, _Up*) [with _Tp = const
short unsigned int; _Up = short unsigned int; bool _IsMove = false]’,
    inlined from ‘_OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove =
false; _II = const short unsigned int*; _OI = short unsigned int*]’ at
/usr/include/c++/13.1.1/bits/stl_algobase.h:506:30,
    inlined from ‘_OI std::__copy_move_a1(_II, _II, _OI) [with bool _IsMove =
false; _II = const short unsigned int*; _OI = short unsigned int*]’ at
/usr/include/c++/13.1.1/bits/stl_algobase.h:533:42,
    inlined from ‘_OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove =
false; _II = const short unsigned int*; _OI = short unsigned int*]’ at
/usr/include/c++/13.1.1/bits/stl_algobase.h:540:31,
    inlined from ‘_OI std::copy(_II, _II, _OI) [with _II = const short unsigned
int*; _OI = short unsigned int*]’ at
/usr/include/c++/13.1.1/bits/stl_algobase.h:633:7,
    inlined from ‘static _ForwardIterator
std::__uninitialized_copy<true>::__uninit_copy(_InputIterator, _InputIterator,
_ForwardIterator) [with _InputIterator = const short unsigned int*;
_ForwardIterator = short unsigned int*]’ at
/usr/include/c++/13.1.1/bits/stl_uninitialized.h:147:27,
    inlined from ‘_ForwardIterator std::uninitialized_copy(_InputIterator,
_InputIterator, _ForwardIterator) [with _InputIterator = const short unsigned
int*; _ForwardIterator = short unsigned int*]’ at
/usr/include/c++/13.1.1/bits/stl_uninitialized.h:185:15,
    inlined from ‘_ForwardIterator std::__uninitialized_copy_a(_InputIterator,
_InputIterator, _ForwardIterator, allocator<_Tp>&) [with _InputIterator = const
short unsigned int*; _ForwardIterator = short unsigned int*; _Tp = short
unsigned int]’ at /usr/include/c++/13.1.1/bits/stl_uninitialized.h:373:37,
    inlined from ‘void std::vector<_Tp,
_Alloc>::_M_range_initialize(_ForwardIterator, _ForwardIterator,
std::forward_iterator_tag) [with _ForwardIterator = const short unsigned int*;
_Tp = short unsigned int; _Alloc = std::allocator<short unsigned int>]’ at
/usr/include/c++/13.1.1/bits/stl_vector.h:1692:33,
    inlined from ‘std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>,
const allocator_type&) [with _Tp = short unsigned int; _Alloc =
std::allocator<short unsigned int>]’ at
/usr/include/c++/13.1.1/bits/stl_vector.h:679:21,
    inlined from ‘constexpr Data::Data()’ at main.cpp:4:8,
    inlined from ‘int main()’ at main.cpp:10:8:
/usr/include/c++/13.1.1/bits/stl_algobase.h:437:30: error: using a dangling
pointer to ‘C.0’ [-Werror=dangling-pointer=]
  437 |             __builtin_memmove(__result, __first, sizeof(_Tp) * _Num);
      |             ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp: In function ‘int main()’:
main.cpp:4:8: note: ‘C.0’ declared here
    4 | struct Data {
      |        ^~~~
cc1plus: all warnings being treated as errors
```

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2023-06-23 10:30 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-31 10:03 [Bug c++/110055] New: Dangling pointer warning inside std::vector on RISC-V spriteovo at gmail dot com
2023-05-31 10:05 ` [Bug c++/110055] " spriteovo at gmail dot com
2023-05-31 13:32 ` spriteovo at gmail dot com
2023-05-31 23:46 ` [Bug middle-end/110055] " pinskia at gcc dot gnu.org
2023-05-31 23:47 ` pinskia at gcc dot gnu.org
2023-06-01  0:07 ` pinskia at gcc dot gnu.org
2023-06-02  7:13 ` rguenth at gcc dot gnu.org
2023-06-02  7:25 ` rguenth at gcc dot gnu.org
2023-06-05 11:15 ` spriteovo at gmail dot com
2023-06-06  8:30 ` cvs-commit at gcc dot gnu.org
2023-06-06  8:41 ` [Bug middle-end/110055] [13 Regression] " rguenth at gcc dot gnu.org
2023-06-23 10:30 ` cvs-commit at gcc dot gnu.org
2023-06-23 10:30 ` rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).