This is the mail archive of the
mailing list for the GCC project.
Re: [C/C++ PATCH] Implement -Wsizeof-array-argument (PR c/6940)
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: Marek Polacek <polacek at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Jason Merrill <jason at redhat dot com>, Jakub Jelinek <jakub at redhat dot com>
- Date: Fri, 27 Jun 2014 17:15:15 +0000
- Subject: Re: [C/C++ PATCH] Implement -Wsizeof-array-argument (PR c/6940)
- Authentication-results: sourceware.org; auth=none
- References: <20140626222238 dot GF489 at redhat dot com>
On Fri, 27 Jun 2014, Marek Polacek wrote:
> The following is a revamped patch for -Wsizeof-array-argument. Almost two
> months back there was an initial attempt by Prathamesh:
> <https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00142.html>, but that patch
> never made it in. This version implements the warning for both C and C++
> FEs, adds more testing, enables the warning by default (I can move it to
> -Wall, of course), makes the warning work properly even for multidimensional
> arrays, etc.
> Its purpose is to detect suspicious usage of the sizeof operator on an array
> function parameter. A few years back I fixed exactly this kind of bug in
> elfutils - so -Wsizeof-array-argument might be indeed useful. (The warning didn't
> trigger during GCC bootstrap though.)
> Jason/Joseph, could you please look at the C++, resp. C FE parts?
The C changes are OK.
Joseph S. Myers