aboutsummaryrefslogtreecommitdiff
path: root/gcc/go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2024-11-28 13:14:34 -0800
committerIan Lance Taylor <iant@golang.org>2024-11-29 13:02:01 -0800
commited712cfe2e826cd846705defb1f6ae391baecb3d (patch)
tree3bb4ef788f45d9453f4ff54da6e8cbbb659e84f5 /gcc/go
parent1a1ac4f062980499f897552b0f7bde18d034cef3 (diff)
downloadgcc-ed712cfe2e826cd846705defb1f6ae391baecb3d.zip
gcc-ed712cfe2e826cd846705defb1f6ae391baecb3d.tar.gz
gcc-ed712cfe2e826cd846705defb1f6ae391baecb3d.tar.bz2
compiler: increase buffer size to avoid warning
GCC has a new -Wformat-truncation warning that triggers on this code: ../../gcc/go/gofrontend/go-encode-id.cc: In function 'std::string go_encode_id(const std::string&)': ../../gcc/go/gofrontend/go-encode-id.cc:176:48: error: '%02x' directive output may be truncated writing between 2 and 8 bytes into a region of size 6 [-Werror=format-truncation=] 176 | snprintf(buf, sizeof buf, "_x%02x", c); | ^~~~ ../../gcc/go/gofrontend/go-encode-id.cc:176:45: note: directive argument in the range [128, 4294967295] 176 | snprintf(buf, sizeof buf, "_x%02x", c); | ^~~~~~~~ ../../gcc/go/gofrontend/go-encode-id.cc:176:27: note: 'snprintf' output between 5 and 11 bytes into a destination of size 8 176 | snprintf(buf, sizeof buf, "_x%02x", c); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The code is safe, because the value of c is known to be >= 0 && <= 0xff. But it's difficult for the compiler to know that. Bump the buffer size to avoid the warning. Fixes PR go/117833 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/632455
Diffstat (limited to 'gcc/go')
-rw-r--r--gcc/go/gofrontend/MERGE2
-rw-r--r--gcc/go/gofrontend/go-encode-id.cc2
2 files changed, 2 insertions, 2 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 59badf8..3bd755c 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-f9ea9801058aa98a421784da12b76cda0b4c6cf2
+dfe585bf82380630697e96c249de825c5f655afe
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
diff --git a/gcc/go/gofrontend/go-encode-id.cc b/gcc/go/gofrontend/go-encode-id.cc
index 7ab65f5..5c82aa7 100644
--- a/gcc/go/gofrontend/go-encode-id.cc
+++ b/gcc/go/gofrontend/go-encode-id.cc
@@ -172,7 +172,7 @@ go_encode_id(const std::string &id)
}
else
{
- char buf[8];
+ char buf[16];
snprintf(buf, sizeof buf, "_x%02x", c);
ret.append(buf);
}