[Bug c++/102466] New: -O3 -fsanitize=undefined causes warnings (writing 2 bytes into a region of size 0)

unlvsur at live dot com gcc-bugzilla@gcc.gnu.org
Thu Sep 23 07:08:27 GMT 2021


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

            Bug ID: 102466
           Summary: -O3 -fsanitize=undefined causes warnings  (writing 2
                    bytes into a region of size 0)
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: unlvsur at live dot com
  Target Milestone: ---

Created attachment 51503
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51503&action=edit
Preprocessed file

without -fsanitize=undefined or use -O2 won't trigger the warning here

cqwrteur@Home-Server:~/fast_io/examples/0021.kernel_driver$ g++ -S main.cc
-std=c++20 -I../../include  -s -fno-exceptions -fno-rtti -fsanitize=undefined
-O3 -ffreestanding
In function 'constexpr void
fast_io::linux::print_status_define(fast_io::linux::basic_kpr<ch_type>, Args
...) [with bool line = true; ch_type = char; Args =
{fast_io::basic_io_scatter_t<char>,
fast_io::manipulators::scalar_manip_t<fast_io::manipulators::scalar_flags{10,
false, false, false, false, false, false, false, true, false, false, false,
fast_io::manipulators::scalar_placement::none,
fast_io::manipulators::floating_format::fixed,
fast_io::manipulators::lc_time_flag::none}, int>,
fast_io::basic_io_scatter_t<char>, fast_io::basic_io_scatter_t<char>,
fast_io::manipulators::scalar_manip_t<fast_io::manipulators::scalar_flags{10,
false, false, false, false, false, false, false, true, false, false, false,
fast_io::manipulators::scalar_placement::none,
fast_io::manipulators::floating_format::fixed,
fast_io::manipulators::lc_time_flag::none}, int>,
fast_io::manipulators::scalar_manip_t<fast_io::manipulators::scalar_flags{10,
false, false, false, false, false, false, false, true, false, false, false,
fast_io::manipulators::scalar_placement::none,
fast_io::manipulators::floating_format::fixed,
fast_io::manipulators::lc_time_flag::none}, unsigned int>}]':
cc1plus: warning: writing 2 bytes into a region of size 0
[-Wstringop-overflow=]
cc1plus: warning: writing 2 bytes into a region of size 0
[-Wstringop-overflow=]
cc1plus: warning: writing 2 bytes into a region of size 0
[-Wstringop-overflow=]
cc1plus: warning: writing 2 bytes into a region of size 0
[-Wstringop-overflow=]
cc1plus: warning: writing 2 bytes into a region of size 0
[-Wstringop-overflow=]
cc1plus: warning: writing 2 bytes into a region of size 0
[-Wstringop-overflow=]
cc1plus: warning: writing 2 bytes into a region of size 0
[-Wstringop-overflow=]
cc1plus: warning: writing 2 bytes into a region of size 0
[-Wstringop-overflow=]
cc1plus: warning: writing 2 bytes into a region of size 0
[-Wstringop-overflow=]
cc1plus: warning: writing 2 bytes into a region of size 0
[-Wstringop-overflow=]
cc1plus: warning: writing 2 bytes into a region of size 0
[-Wstringop-overflow=]



This is freestanding code to reduce size of processor file. You can just treat
printk function as printf. -ffreestanding does not affect whether the warning
would emit or not.

Do not know whether it is a false positive.


More information about the Gcc-bugs mailing list