public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/99131] New: gcc doesn't detect missing comma in array initialisation
@ 2021-02-17 10:35 dcb314 at hotmail dot com
2021-02-17 11:32 ` [Bug c/99131] " redi at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: dcb314 at hotmail dot com @ 2021-02-17 10:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99131
Bug ID: 99131
Summary: gcc doesn't detect missing comma in array
initialisation
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: dcb314 at hotmail dot com
Target Milestone: ---
For this C code:
const char * a[ 4] = {
" fred ",
" bert "
" harry ",
" eric "
};
Note missing "," on the bert line. gcc doesn't say very much:
$ /home/dcb/gcc/results/bin/gcc -c -g -O2 -Wall -Wextra feb17f.cc
$
Here is a recent clang doing something more useful:
$ /home/dcb/llvm/clang1200rc1/bin/clang++ -c -g -O2 -Wall -Wextra feb17f.cc
feb17f.cc:7:2: warning: suspicious concatenation of string literals in an array
initialization; did you mean to separate the elements with a comma?
[-Wstring-concatenation]
" harry ",
^
feb17f.cc:6:2: note: place parentheses around the string literal to silence
warning
" bert "
^
1 warning generated.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/99131] gcc doesn't detect missing comma in array initialisation
2021-02-17 10:35 [Bug c/99131] New: gcc doesn't detect missing comma in array initialisation dcb314 at hotmail dot com
@ 2021-02-17 11:32 ` redi at gcc dot gnu.org
2021-02-17 15:25 ` egallager at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2021-02-17 11:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99131
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Severity|normal |enhancement
Blocks| |87403
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87403
[Bug 87403] [Meta-bug] Issues that suggest a new warning
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/99131] gcc doesn't detect missing comma in array initialisation
2021-02-17 10:35 [Bug c/99131] New: gcc doesn't detect missing comma in array initialisation dcb314 at hotmail dot com
2021-02-17 11:32 ` [Bug c/99131] " redi at gcc dot gnu.org
@ 2021-02-17 15:25 ` egallager at gcc dot gnu.org
2021-02-17 16:33 ` dcb314 at hotmail dot com
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: egallager at gcc dot gnu.org @ 2021-02-17 15:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99131
Eric Gallager <egallager at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |egallager at gcc dot gnu.org
Status|UNCONFIRMED |NEW
Last reconfirmed| |2021-02-17
Ever confirmed|0 |1
--- Comment #1 from Eric Gallager <egallager at gcc dot gnu.org> ---
Having this warning would have saved me a lot of grief trying to hunt down a
particular bug I remember having to deal with in the past; confirmed.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/99131] gcc doesn't detect missing comma in array initialisation
2021-02-17 10:35 [Bug c/99131] New: gcc doesn't detect missing comma in array initialisation dcb314 at hotmail dot com
2021-02-17 11:32 ` [Bug c/99131] " redi at gcc dot gnu.org
2021-02-17 15:25 ` egallager at gcc dot gnu.org
@ 2021-02-17 16:33 ` dcb314 at hotmail dot com
2021-03-15 20:45 ` [Bug c/99131] gcc doesn't detect missing comma in array initialisation [-Wstring-concatenation] egallager at gcc dot gnu.org
2022-01-11 21:04 ` dcb314 at hotmail dot com
4 siblings, 0 replies; 6+ messages in thread
From: dcb314 at hotmail dot com @ 2021-02-17 16:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99131
--- Comment #2 from David Binderman <dcb314 at hotmail dot com> ---
I usually write code that compiles warning free on both gcc and clang.
I only noticed this difference between gcc and clang as a result
of compiling the latest release of the tor browser. I thought it
would be good to generalise it.
I guess there must be some way to get both gcc and clang to emit
all possible warning messages they can, then diff the two lists,
to find out where one compiler could be enhanced. The strings
command might be the way forward on this.
I'd be happy to help with testing any prototype implementation.
Interesting, my usual static analyser, cppcheck, has nothing to say
also, so that's probably worth a bug report too.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/99131] gcc doesn't detect missing comma in array initialisation [-Wstring-concatenation]
2021-02-17 10:35 [Bug c/99131] New: gcc doesn't detect missing comma in array initialisation dcb314 at hotmail dot com
` (2 preceding siblings ...)
2021-02-17 16:33 ` dcb314 at hotmail dot com
@ 2021-03-15 20:45 ` egallager at gcc dot gnu.org
2022-01-11 21:04 ` dcb314 at hotmail dot com
4 siblings, 0 replies; 6+ messages in thread
From: egallager at gcc dot gnu.org @ 2021-03-15 20:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99131
Eric Gallager <egallager at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|gcc doesn't detect missing |gcc doesn't detect missing
|comma in array |comma in array
|initialisation |initialisation
| |[-Wstring-concatenation]
CC| |dmalcolm at gcc dot gnu.org,
| |marxin at gcc dot gnu.org
--- Comment #3 from Eric Gallager <egallager at gcc dot gnu.org> ---
Adding clang's name for this warning to the title for easier findability. Also
this warning has found a few issues in GCC's own code; see here:
https://gcc.gnu.org/pipermail/gcc-patches/2021-March/566749.html
...and here:
https://gcc.gnu.org/pipermail/gcc-patches/2021-March/566750.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/99131] gcc doesn't detect missing comma in array initialisation [-Wstring-concatenation]
2021-02-17 10:35 [Bug c/99131] New: gcc doesn't detect missing comma in array initialisation dcb314 at hotmail dot com
` (3 preceding siblings ...)
2021-03-15 20:45 ` [Bug c/99131] gcc doesn't detect missing comma in array initialisation [-Wstring-concatenation] egallager at gcc dot gnu.org
@ 2022-01-11 21:04 ` dcb314 at hotmail dot com
4 siblings, 0 replies; 6+ messages in thread
From: dcb314 at hotmail dot com @ 2022-01-11 21:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99131
--- Comment #4 from David Binderman <dcb314 at hotmail dot com> ---
Interestingly, I compiled fedora rawhide with clang and found
a whopping 247 cases of this warning across 11 packages.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-01-11 21:04 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-17 10:35 [Bug c/99131] New: gcc doesn't detect missing comma in array initialisation dcb314 at hotmail dot com
2021-02-17 11:32 ` [Bug c/99131] " redi at gcc dot gnu.org
2021-02-17 15:25 ` egallager at gcc dot gnu.org
2021-02-17 16:33 ` dcb314 at hotmail dot com
2021-03-15 20:45 ` [Bug c/99131] gcc doesn't detect missing comma in array initialisation [-Wstring-concatenation] egallager at gcc dot gnu.org
2022-01-11 21:04 ` dcb314 at hotmail dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).