[Bug c/114205] New: Miscompilation: the use of __builtin_object_size cause asan failure.
141242068 at smail dot nju.edu.cn
gcc-bugzilla@gcc.gnu.org
Sat Mar 2 07:51:57 GMT 2024
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
More information about the Gcc-bugs
mailing list