This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

c/6939: taking sizeof array parameter should trigger a warning


>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:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]