public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/113775] New: Bogus Wstringop-overflow in __atomic_load_n combined with sanitizer flags
@ 2024-02-05 18:50 disservin.social at gmail dot com
  2024-02-05 18:54 ` [Bug tree-optimization/113775] " pinskia at gcc dot gnu.org
  2024-02-06  7:51 ` rguenth at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: disservin.social at gmail dot com @ 2024-02-05 18:50 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 113775
           Summary: Bogus Wstringop-overflow in __atomic_load_n combined
                    with sanitizer flags
           Product: gcc
           Version: 13.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: disservin.social at gmail dot com
  Target Milestone: ---

Created attachment 57330
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57330&action=edit
reproduction

GCC emits a bogus warning in the attached reproduction when compiled with
sanitizers flags and O3.
-O3 -std=c++17 -Wall -fsanitize=undefined -fsanitize=address

See

In file included from
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/atomic:41,
                 from <source>:1:
In member function 'std::__atomic_base<_IntTp>::__int_type
std::__atomic_base<_IntTp>::load(std::memory_order) const [with _ITp = bool]',
    inlined from 'std::atomic<bool>::operator bool() const' at
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/atomic:87:26,
    inlined from 'void Foo::foo()' at <source>:22:32:
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/atomic_base.h:505:31:
warning: 'unsigned char __atomic_load_1(const volatile void*, int)' writing 1
byte into a region of size 0 overflows the destination [-Wstringop-overflow=]
  505 |         return __atomic_load_n(&_M_i, int(__m));
      |                ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
In member function 'void Foo::foo()':
cc1plus: note: destination object is likely at address zero
Compiler returned: 0

I had a look at the bugs linked to
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88443, but I couldnt find a
similar scenario. Apologies if it is already known.

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

* [Bug tree-optimization/113775] Bogus Wstringop-overflow in __atomic_load_n combined with sanitizer flags
  2024-02-05 18:50 [Bug tree-optimization/113775] New: Bogus Wstringop-overflow in __atomic_load_n combined with sanitizer flags disservin.social at gmail dot com
@ 2024-02-05 18:54 ` pinskia at gcc dot gnu.org
  2024-02-06  7:51 ` rguenth at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-05 18:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
See
https://gcc.gnu.org/onlinedocs/gcc-13.2.0/gcc/Instrumentation-Options.html#index-fsanitize_003dundefined 


Note that sanitizers tend to increase the rate of false positive warnings, most
notably those around -Wmaybe-uninitialized. We recommend against combining
-Werror and [the use of] sanitizers.

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

* [Bug tree-optimization/113775] Bogus Wstringop-overflow in __atomic_load_n combined with sanitizer flags
  2024-02-05 18:50 [Bug tree-optimization/113775] New: Bogus Wstringop-overflow in __atomic_load_n combined with sanitizer flags disservin.social at gmail dot com
  2024-02-05 18:54 ` [Bug tree-optimization/113775] " pinskia at gcc dot gnu.org
@ 2024-02-06  7:51 ` rguenth at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-02-06  7:51 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Yeah, the

'cc1plus: note: destination object is likely at address zero'

message hints at that we likely diagnose a threaded path where the pointer
is zero.  We were likely inclined to perform the threading by dynamic
checks inserted by the sanitizer.

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

end of thread, other threads:[~2024-02-06  7:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-05 18:50 [Bug tree-optimization/113775] New: Bogus Wstringop-overflow in __atomic_load_n combined with sanitizer flags disservin.social at gmail dot com
2024-02-05 18:54 ` [Bug tree-optimization/113775] " pinskia at gcc dot gnu.org
2024-02-06  7:51 ` 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).