This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c/6939: taking sizeof array parameter should trigger a warning
- From: Marco dot Franzen at bigfoot dot com
- To: gcc-gnats at gcc dot gnu dot org
- Date: 5 Jun 2002 21:06:10 -0000
- Subject: c/6939: taking sizeof array parameter should trigger a warning
- Reply-to: Marco dot Franzen at bigfoot dot com
>Number: 6939
>Category: c
>Synopsis: taking sizeof array parameter should trigger a warning
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: unassigned
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Wed Jun 05 14:16:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Marco Franzen
>Release: gcc-3.1
>Organization:
>Environment:
>Description:
Neither the C nor the C++ front-end of GCC 3.1 issues a warning for this. (I tried -W -Wall for both.)
I know the generated code is absolutely correct, but a warning would be in order (and should probably be on by default, given it will be rare outside obfuscation contests).
>How-To-Repeat:
int func(int array[], int* pointer)
{
int n1 = sizeof(array); // no, it isn't
int n2 = sizeof(pointer);
return n1 - n2;
}
int main()
{
int v[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
return func (v, v);
}
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: