https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120621
Bug ID: 120621
Summary: COBOL isn't built with STRICT_WARN
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: cobol
Assignee: unassigned at gcc dot gnu.org
Reporter: ro at gcc dot gnu.org
CC: jklowden at gcc dot gnu.org, rdubner at gcc dot gnu.org
Target Milestone: ---
I recently noticed that building the COBOL frontend produces quite a number of
warnings, even on Linux/x86_64:
/vol/gcc/src/hg/master/local/gcc/cobol/symbols.cc: In member function ‘char*
cbl_file_t::keys_str() const’:
/vol/gcc/src/hg/master/local/gcc/cobol/symbols.cc:4578:8: warning: writing 1
byte into a region of size 0 [-Wstringop-overflow=]
4578 | *p++ = '[';
| ~~~~~^~~~~
/vol/gcc/src/hg/master/local/gcc/cobol/symbols.cc:4575:45: note: destination
object of size 0 allocated by ‘xcalloc’
4575 | char *output = static_cast<char*>( xcalloc(1, n) ), *p = output;
| ~~~~~~~^~~~~~
/vol/gcc/src/hg/master/local/gcc/cobol/symbols.cc:4585:8: warning: writing 1
byte into a region of size 0 [-Wstringop-overflow=]
4585 | *p++ = ']';
| ~~~~~^~~~~
/vol/gcc/src/hg/master/local/gcc/cobol/symbols.cc:4575:45: note: at offset 1
into destination object of size 0 allocated by ‘xcalloc’
4575 | char *output = static_cast<char*>( xcalloc(1, n) ), *p = output;
| ~~~~~~~^~~~~~
There are several more on 32-bit hosts, e.g. Solaris/i386 has
/vol/gcc/src/hg/master/local/gcc/cobol/genapi.cc: In function ‘tree_node*
parser_compile_ecs(const std::vector<long long unsigned int>&)’:
/vol/gcc/src/hg/master/local/gcc/cobol/genapi.cc:960:44: warning: format ‘%ld’
expects argument of type ‘long int’, but argument 4 has type ‘std::vector<long
long unsigned int>::size_type’ {aka ‘unsigned int’} [-Wformat=]
960 | snprintf(ach, sizeof(ach), " Size is %ld; retval is %p",
ecs.size(), retval);
| ~~^ ~~~~~~~~~~
| | |
| long int
std::vector<long long unsigned int>::size_type {aka unsigned int}
| %d
/vol/gcc/src/hg/master/local/gcc/cobol/genapi.cc:968:44: warning: format ‘%ld’
expects argument of type ‘long int’, but argument 4 has type ‘std::vector<long
long unsigned int>::size_type’ {aka ‘unsigned int’} [-Wformat=]
968 | snprintf(ach, sizeof(ach), " Size is %ld; retval is %p",
ecs.size(), retval);
| ~~^ ~~~~~~~~~~
| | |
| long int
std::vector<long long unsigned int>::size_type {aka unsigned int}
| %d
/vol/gcc/src/hg/master/local/gcc/cobol/genapi.cc: In function ‘tree_node*
parser_compile_dcls(const std::vector<long long unsigned int>&)’:
/vol/gcc/src/hg/master/local/gcc/cobol/genapi.cc:1007:44: warning: format ‘%ld’
expects argument of type ‘long int’, but argument 4 has type ‘std::vector<long
long unsigned int>::size_type’ {aka ‘unsigned int’} [-Wformat=]
1007 | snprintf(ach, sizeof(ach), " Size is %ld; retval is %p",
dcls.size(), retval);
| ~~^
~~~~~~~~~~~
| | |
| long int
std::vector<long long unsigned int>::size_type {aka unsigned int}
| %d
/vol/gcc/src/hg/master/local/gcc/cobol/genapi.cc:1015:44: warning: format ‘%ld’
expects argument of type ‘long int’, but argument 4 has type ‘std::vector<long
long unsigned int>::size_type’ {aka ‘unsigned int’} [-Wformat=]
1015 | snprintf(ach, sizeof(ach), " Size is %ld; retval is %p",
dcls.size(), retval);
| ~~^
~~~~~~~~~~~
| | |
| long int
std::vector<long long unsigned int>::size_type {aka unsigned int}
| %d
Looking closer, I noticed that unlike any other frontend COBOL doesn't enable
STRICT_WARN in gcc/cobol/Make-lang.in. The others have something like
rust-warn = $(STRICT_WARN)
I guess that should be changed, allowing to catch a couple of issues as in the
other frontends.