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

            Bug ID: 88997
           Summary: Implicit constructors created with line numbers
           Product: gcc
           Version: 8.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jg at jguk dot org
  Target Milestone: ---

Created attachment 45500
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45500&action=edit
test case

Hello

Could the implicit copy constructor be created with line numbers? Maybe also
source code saved as a temp file?

Or alternatively the struct could be used (example output below)

Test case attached. It is clearer to know which variable the runtime error
relates

e.g. expected output something like:

$ ./undef
undef.cpp:9:10: runtime error: load of value 112, which is not a valid value
for type 'bool'
undef.cpp:10:10: runtime error: load of value 102, which is not a valid value
for type 'bool'
undef.cpp:11:10: runtime error: load of value 172, which is not a valid value
for type 'bool'



Actual output:

$ export UBSAN_OPTIONS=print_stacktrace=1

$ ./undef
undef.cpp:6:16: runtime error: load of value 112, which is not a valid value
for type 'bool'
    #0 0x55e6f8f5fa63 in testt::testt(testt const&)
/home/jonny/code/sanitize_undefined/undef.cpp:6
    #1 0x55e6f8f5fd85 in void __gnu_cxx::new_allocator<testt>::construct<testt,
testt const&>(testt*, testt const&) /usr/include/c++/8/ext/new_allocator.h:136
    #2 0x55e6f8f5e911 in void std::allocator_traits<std::allocator<testt>
>::construct<testt, testt const&>(std::allocator<testt>&, testt*, testt const&)
/usr/include/c++/8/bits/alloc_traits.h:475
    #3 0x55e6f8f5eecc in void std::vector<testt, std::allocator<testt>
>::_M_realloc_insert<testt const&>(__gnu_cxx::__normal_iterator<testt*,
std::vector<testt, std::allocator<testt> > >, testt const&)
/usr/include/c++/8/bits/vector.tcc:436
    #4 0x55e6f8f5e551 in std::vector<testt, std::allocator<testt>
>::push_back(testt const&) /usr/include/c++/8/bits/stl_vector.h:1085
    #5 0x55e6f8f5dd97 in main /home/jonny/code/sanitize_undefined/undef.cpp:18
    #6 0x7fcbbf157b96 in __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
    #7 0x55e6f8f5dc09 in _start
(/home/jonny/code/sanitize_undefined/undef+0x7c09)

undef.cpp:6:16: runtime error: load of value 76, which is not a valid value for
type 'bool'
    #0 0x55e6f8f5fb61 in testt::testt(testt const&)
/home/jonny/code/sanitize_undefined/undef.cpp:6
    #1 0x55e6f8f5fd85 in void __gnu_cxx::new_allocator<testt>::construct<testt,
testt const&>(testt*, testt const&) /usr/include/c++/8/ext/new_allocator.h:136
    #2 0x55e6f8f5e911 in void std::allocator_traits<std::allocator<testt>
>::construct<testt, testt const&>(std::allocator<testt>&, testt*, testt const&)
/usr/include/c++/8/bits/alloc_traits.h:475
    #3 0x55e6f8f5eecc in void std::vector<testt, std::allocator<testt>
>::_M_realloc_insert<testt const&>(__gnu_cxx::__normal_iterator<testt*,
std::vector<testt, std::allocator<testt> > >, testt const&)
/usr/include/c++/8/bits/vector.tcc:436
    #4 0x55e6f8f5e551 in std::vector<testt, std::allocator<testt>
>::push_back(testt const&) /usr/include/c++/8/bits/stl_vector.h:1085
    #5 0x55e6f8f5dd97 in main /home/jonny/code/sanitize_undefined/undef.cpp:18
    #6 0x7fcbbf157b96 in __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
    #7 0x55e6f8f5dc09 in _start
(/home/jonny/code/sanitize_undefined/undef+0x7c09)

undef.cpp:6:16: runtime error: load of value 22, which is not a valid value for
type 'bool'
    #0 0x55e6f8f5fc64 in testt::testt(testt const&)
/home/jonny/code/sanitize_undefined/undef.cpp:6
    #1 0x55e6f8f5fd85 in void __gnu_cxx::new_allocator<testt>::construct<testt,
testt const&>(testt*, testt const&) /usr/include/c++/8/ext/new_allocator.h:136
    #2 0x55e6f8f5e911 in void std::allocator_traits<std::allocator<testt>
>::construct<testt, testt const&>(std::allocator<testt>&, testt*, testt const&)
/usr/include/c++/8/bits/alloc_traits.h:475
    #3 0x55e6f8f5eecc in void std::vector<testt, std::allocator<testt>
>::_M_realloc_insert<testt const&>(__gnu_cxx::__normal_iterator<testt*,
std::vector<testt, std::allocator<testt> > >, testt const&)
/usr/include/c++/8/bits/vector.tcc:436
    #4 0x55e6f8f5e551 in std::vector<testt, std::allocator<testt>
>::push_back(testt const&) /usr/include/c++/8/bits/stl_vector.h:1085
    #5 0x55e6f8f5dd97 in main /home/jonny/code/sanitize_undefined/undef.cpp:18
    #6 0x7fcbbf157b96 in __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
    #7 0x55e6f8f5dc09 in _start
(/home/jonny/code/sanitize_undefined/undef+0x7c09)

Reply via email to