public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/102466] New: -O3 -fsanitize=undefined causes warnings (writing 2 bytes into a region of size 0)
@ 2021-09-23 7:08 unlvsur at live dot com
2021-09-27 14:00 ` [Bug tree-optimization/102466] " marxin at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: unlvsur at live dot com @ 2021-09-23 7:08 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/102466] -O3 -fsanitize=undefined causes warnings (writing 2 bytes into a region of size 0)
2021-09-23 7:08 [Bug c++/102466] New: -O3 -fsanitize=undefined causes warnings (writing 2 bytes into a region of size 0) unlvsur at live dot com
@ 2021-09-27 14:00 ` marxin at gcc dot gnu.org
2021-09-27 21:37 ` msebor at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-09-27 14:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102466
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |marxin at gcc dot gnu.org
--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
It's very likely a false positive. We have quite some duplicates where we
explain that enabling sanitizers can lead to false-positive warnings.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/102466] -O3 -fsanitize=undefined causes warnings (writing 2 bytes into a region of size 0)
2021-09-23 7:08 [Bug c++/102466] New: -O3 -fsanitize=undefined causes warnings (writing 2 bytes into a region of size 0) unlvsur at live dot com
2021-09-27 14:00 ` [Bug tree-optimization/102466] " marxin at gcc dot gnu.org
@ 2021-09-27 21:37 ` msebor at gcc dot gnu.org
2022-03-29 14:20 ` mathieu.malaterre at gmail dot com
2022-03-29 14:22 ` mathieu.malaterre at gmail dot com
3 siblings, 0 replies; 5+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-09-27 21:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102466
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
CC| |msebor at gcc dot gnu.org
Last reconfirmed| |2021-09-27
Blocks| |88443
Status|UNCONFIRMED |NEW
--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
Confirmed. As Martin indicated in comment #1, the UBSAN sanitization is
causing the warning to trigger. The IL the first instance is issued for is
below (-fdump-tree-strlen):
if (iter_554 == 0B)
goto <bb 31>; [0.00%]
else
goto <bb 32>; [100.00%]
<bb 31> [count: 0]:
__builtin___ubsan_handle_nonnull_arg (&*.Lubsan_data478);
<bb 32> [local count: 850510933]:
if (_560 == 0B)
goto <bb 33>; [0.00%]
else
goto <bb 34>; [100.00%]
<bb 33> [count: 0]:
__builtin___ubsan_handle_nonnull_arg (&*.Lubsan_data479);
<bb 34> [local count: 850510933]: <<< iter_554
is null
_565 = MEM <short unsigned int> [(char * {ref-all})_558];
MEM <short unsigned int> [(char * {ref-all})iter_554] = _565; <<<
-Wstringop-overflow
.UBSAN_PTR (iter_554, 2);
The problem is likely a duplicate of one of the existing reports of the same
problem.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88443
[Bug 88443] [meta-bug] bogus/missing -Wstringop-overflow warnings
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/102466] -O3 -fsanitize=undefined causes warnings (writing 2 bytes into a region of size 0)
2021-09-23 7:08 [Bug c++/102466] New: -O3 -fsanitize=undefined causes warnings (writing 2 bytes into a region of size 0) unlvsur at live dot com
2021-09-27 14:00 ` [Bug tree-optimization/102466] " marxin at gcc dot gnu.org
2021-09-27 21:37 ` msebor at gcc dot gnu.org
@ 2022-03-29 14:20 ` mathieu.malaterre at gmail dot com
2022-03-29 14:22 ` mathieu.malaterre at gmail dot com
3 siblings, 0 replies; 5+ messages in thread
From: mathieu.malaterre at gmail dot com @ 2022-03-29 14:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102466
Mathieu Malaterre <mathieu.malaterre at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mathieu.malaterre at gmail dot com
--- Comment #3 from Mathieu Malaterre <mathieu.malaterre at gmail dot com> ---
This is also triggered in libjxl codebase:
* https://github.com/libjxl/libjxl/blob/main/tools/fuzzer_corpus.cc
/usr/include/c++/11/bits/stl_algobase.h:431:30: warning: 'void*
__builtin_memmove(void*, const void*, long unsigned int)' writing 1 or more
bytes into a region of size 0 overflows the destination [-Wstringop-overflow=]
431 | __builtin_memmove(__result, __first, sizeof(_Tp) * _Num);
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/102466] -O3 -fsanitize=undefined causes warnings (writing 2 bytes into a region of size 0)
2021-09-23 7:08 [Bug c++/102466] New: -O3 -fsanitize=undefined causes warnings (writing 2 bytes into a region of size 0) unlvsur at live dot com
` (2 preceding siblings ...)
2022-03-29 14:20 ` mathieu.malaterre at gmail dot com
@ 2022-03-29 14:22 ` mathieu.malaterre at gmail dot com
3 siblings, 0 replies; 5+ messages in thread
From: mathieu.malaterre at gmail dot com @ 2022-03-29 14:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102466
--- Comment #4 from Mathieu Malaterre <mathieu.malaterre at gmail dot com> ---
I can reproduce it using -Wall -fsanitize=undefined -O2
* https://github.com/malaterre/PublicRep/tree/master/gcc/libjxl
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-03-29 14:22 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-23 7:08 [Bug c++/102466] New: -O3 -fsanitize=undefined causes warnings (writing 2 bytes into a region of size 0) unlvsur at live dot com
2021-09-27 14:00 ` [Bug tree-optimization/102466] " marxin at gcc dot gnu.org
2021-09-27 21:37 ` msebor at gcc dot gnu.org
2022-03-29 14:20 ` mathieu.malaterre at gmail dot com
2022-03-29 14:22 ` mathieu.malaterre at gmail dot com
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).