[Bug sanitizer/107586] gcc trunk missed a stack-buffer-overflow
marxin at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Dec 2 13:20:50 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107586
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|ASSIGNED |RESOLVED
--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
If I hide the constant 70, then I get the error also with -O2:
diff -u pr107586-orig.c pr107586.c
--- pr107586-orig.c 2022-12-02 14:19:49.392836836 +0100
+++ pr107586.c 2022-12-02 14:19:33.096414298 +0100
@@ -3,13 +3,15 @@
int x;
};
+int N = 70;
+
void h(struct a *b)
{
struct a c[70];
int i;
- for (i = 0; i < 70; i++)
+ for (i = 0; i < N; i++)
c[i].x = 1;
- __builtin_memcpy(b, c, 70*sizeof(struct a));
+ __builtin_memcpy(b, c, N*sizeof(struct a));
__builtin_printf("%d\n", b->x);
};
void g()
So the compiler can propagate that, so closing as invalid.
More information about the Gcc-bugs
mailing list