commit | dfe585bf82380630697e96c249de825c5f655afe | [log] [tgz] |
---|---|---|
author | Ian Lance Taylor <iant@golang.org> | Thu Nov 28 13:14:34 2024 -0800 |
committer | Ian Lance Taylor <iant@golang.org> | Fri Nov 29 21:00:35 2024 +0000 |
tree | 57e8c49809602927c3242a5b248e81376d766319 | |
parent | f9ea9801058aa98a421784da12b76cda0b4c6cf2 [diff] |
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 https://gcc.gnu.org/PR117833 Change-Id: I9e23d3a556ddcbf832c7490e12a1a346c643b093 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/632455 Reviewed-by: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
Ian Lance Taylor Last update 15 June 2014
This is a compiler frontend for the Go programming language. The frontend was originally developed at Google, and was released in November 2009. It was originally written by Ian Lance Taylor.
It was originally written for GCC. As of this writing it only supports GCC, but the GCC support has been separated from the rest of the frontend, so supporting another compiler is feasible.
The go subdirectory holds the frontend source code. This is mirrored to the gcc/go subdirectory in the GCC repository.
The libgo subdirectory holds the library source code. This is a copy of the main Go library with various changes appropriate for this compiler. The main Go library is hosted at http://go.googlesource.com/go, in the src directory. The libgo subdirectory is mirrored to the libgo subdirectory in the gcc repository.
To contribute patches to the files in this directory, please see Contributing to the gccgo frontend.
The master copy of these files is hosted in Gerrit (there is a mirror at Github). Changes to these files require signing a Google contributor license agreement. If you are the copyright holder, you will need to agree to the Google Individual Contributor License Agreement. This agreement can be completed online.
If your organization is the copyright holder, the organization will need to agree to the Google Software Grant and Corporate Contributor License Agreement.
If the copyright holder for your code has already completed the agreement in connection with another Google open source project, it does not need to be completed again.