public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/114205] New: Miscompilation: the use of __builtin_object_size cause asan failure.
@ 2024-03-02 7:51 141242068 at smail dot nju.edu.cn
2024-03-02 8:06 ` [Bug c/114205] " pinskia at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: 141242068 at smail dot nju.edu.cn @ 2024-03-02 7:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114205
Bug ID: 114205
Summary: Miscompilation: the use of __builtin_object_size cause
asan failure.
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: 141242068 at smail dot nju.edu.cn
Target Milestone: ---
This program:
```
#include <stdlib.h>
static char a[40];
int main() {
if (__builtin_object_size(&a[0] + 1, 1) == (size_t)-1)
__builtin_abort();
return 0;
}
```
When compiled with `gcc -fsanitize=address`, the result binary reports error.
But if change the branch compare operator from "==" into "!=", then result
binary compiled from `gcc -fsanitize=address` reports nothing.
Error with "==", can be verified on https://gcc.godbolt.org/z/vWxWhYoMT
Normal with "!=", can be verified on https://gcc.godbolt.org/z/sb4bGs76f
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c/114205] Miscompilation: the use of __builtin_object_size cause asan failure.
2024-03-02 7:51 [Bug c/114205] New: Miscompilation: the use of __builtin_object_size cause asan failure 141242068 at smail dot nju.edu.cn
@ 2024-03-02 8:06 ` pinskia at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-02 8:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114205
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|UNCONFIRMED |RESOLVED
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I don't see why you think this is a bug.
-1 returning from __builtin_object_size means it does not know the size.
Without optimization, GCC cannot figure out the size of the object that is
being passed to __builtin_object_size . So at -O0 it aborts.
`-fsanitize=address` will output the error message:
```
AddressSanitizer:DEADLYSIGNAL
=================================================================
==1==ERROR: AddressSanitizer: SEGV on unknown address (pc 0x7f7a49828898 bp
0x7f7a49a1be90 sp 0x7ffc8a097720 T0)
```
When abort is called.
There is nothing wrong here.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-03-02 8:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-02 7:51 [Bug c/114205] New: Miscompilation: the use of __builtin_object_size cause asan failure 141242068 at smail dot nju.edu.cn
2024-03-02 8:06 ` [Bug c/114205] " pinskia 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).