diff options
author | Andrew Pinski <apinski@marvell.com> | 2021-07-15 18:07:09 -0700 |
---|---|---|
committer | Andrew Pinski <apinski@marvell.com> | 2021-07-16 11:51:35 -0700 |
commit | e06b1c5ac00b1bd0339739d3d9377c90852a83c9 (patch) | |
tree | 54ed2ca5cf7ab3eaa128cdf09312be54a45a2472 /gcc | |
parent | 94ba897be8b59ef5926eed4c77fd53812fb20add (diff) | |
download | gcc-e06b1c5ac00b1bd0339739d3d9377c90852a83c9.zip gcc-e06b1c5ac00b1bd0339739d3d9377c90852a83c9.tar.gz gcc-e06b1c5ac00b1bd0339739d3d9377c90852a83c9.tar.bz2 |
Fix PR 101453: ICE with optimize and large integer constant
The problem is the buffer is too small to hold "-O" and
the interger. This fixes the problem by use the correct size
instead.
Changes since v1:
* v2: Use HOST_BITS_PER_LONG and just divide by 3 instead of
3.32.
OK? Bootstrapped and tested on x86_64-linux with no regressions.
gcc/c-family/ChangeLog:
PR c/101453
* c-common.c (parse_optimize_options): Use the correct
size for buffer.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/c-family/c-common.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 681fcc9..fe3657b 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -5798,7 +5798,7 @@ parse_optimize_options (tree args, bool attr_p) if (TREE_CODE (value) == INTEGER_CST) { - char buffer[20]; + char buffer[HOST_BITS_PER_LONG / 3 + 4]; sprintf (buffer, "-O%ld", (long) TREE_INT_CST_LOW (value)); vec_safe_push (optimize_args, ggc_strdup (buffer)); } |