public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/19994] New: warn on parameter name mismatch
@ 2005-02-16 11:10 cyeoh at samba dot org
  2005-02-16 11:13 ` [Bug c/19994] " pinskia at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: cyeoh at samba dot org @ 2005-02-16 11:10 UTC (permalink / raw)
  To: gcc-bugs

Would like to be able to get a warning when parameter names don't match
the prototype. eg. 

void foo(int x, int y);

then doing

void foo(int y, int x)
{
}

should generate a warning.

-- 
           Summary: warn on parameter name mismatch
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: cyeoh at samba dot org
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19994


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c/19994] warn on parameter name mismatch
  2005-02-16 11:10 [Bug c/19994] New: warn on parameter name mismatch cyeoh at samba dot org
@ 2005-02-16 11:13 ` pinskia at gcc dot gnu dot org
  2005-02-16 15:16 ` cyeoh at samba dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-02-16 11:13 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-02-16 04:39 -------
Why, the name in the prototype means nothing.  Yes it would be useful for the first time programer but 
it might get in the way of valid and defined code.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19994


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c/19994] warn on parameter name mismatch
  2005-02-16 11:10 [Bug c/19994] New: warn on parameter name mismatch cyeoh at samba dot org
  2005-02-16 11:13 ` [Bug c/19994] " pinskia at gcc dot gnu dot org
@ 2005-02-16 15:16 ` cyeoh at samba dot org
  2005-02-16 15:27 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: cyeoh at samba dot org @ 2005-02-16 15:16 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cyeoh at samba dot org  2005-02-16 07:05 -------
prototypes in header files can get out of sync with the function definitions (or
parameters are simply get swapped around accidentally) - even with experienced
programmers. 

Users of that interface then get unexpect behaviour. I still think an optional
warning would be useful - and it wouldn't be on by default.

I think it would be fairly unusual that you would want the prototype parameter
names to not match the definition. It wouldn't have to warn if the parameter
names in the prototype were deliberately omitted.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19994


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c/19994] warn on parameter name mismatch
  2005-02-16 11:10 [Bug c/19994] New: warn on parameter name mismatch cyeoh at samba dot org
  2005-02-16 11:13 ` [Bug c/19994] " pinskia at gcc dot gnu dot org
  2005-02-16 15:16 ` cyeoh at samba dot org
@ 2005-02-16 15:27 ` pinskia at gcc dot gnu dot org
  2005-02-16 16:30 ` schlie at comcast dot net
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-02-16 15:27 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-02-16 07:08 -------
One more note from me on this bug forever.
Most people don't use parameter names in prototypes to make sure that this confussion does not 
happen.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19994


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c/19994] warn on parameter name mismatch
  2005-02-16 11:10 [Bug c/19994] New: warn on parameter name mismatch cyeoh at samba dot org
                   ` (2 preceding siblings ...)
  2005-02-16 15:27 ` pinskia at gcc dot gnu dot org
@ 2005-02-16 16:30 ` schlie at comcast dot net
  2005-02-16 17:02 ` schlie at comcast dot net
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: schlie at comcast dot net @ 2005-02-16 16:30 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From schlie at comcast dot net  2005-02-16 11:47 -------
(In reply to comment #3)
> One more note from me on this bug forever.
> Most people don't use parameter names in prototypes to make sure that this confussion does not 
> happen.

Actually, most people do use parameter names in prototypes, as they tend to serve as documentation
of the function's call API, thereby if the function's symbolic parameter names are inconsistent between
it's declaration and definition; GCC should minimally warn if not generate an error, given that these
symbolic names are used as the basis of the code's referance to it's parameters, not parameter order.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19994


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c/19994] warn on parameter name mismatch
  2005-02-16 11:10 [Bug c/19994] New: warn on parameter name mismatch cyeoh at samba dot org
                   ` (3 preceding siblings ...)
  2005-02-16 16:30 ` schlie at comcast dot net
@ 2005-02-16 17:02 ` schlie at comcast dot net
  2005-02-16 18:04 ` joseph at codesourcery dot com
  2005-06-19 22:55 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: schlie at comcast dot net @ 2005-02-16 17:02 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From schlie at comcast dot net  2005-02-16 12:36 -------
(In reply to comment #4)

To be more clear (independant of what most may or may not do, or rely upon), as within the body
of a function definition, given that parameters are referanced by their symbolic name, not postion:

  int apples_per_basket ( int apples, int baskets );

  int function ( int baskets, int apples) {
       return apple / baskets;
      /* i.e. not: return %0 - %1;   referancing parameters by order not name, which C doen't support */
   }

Then it's reasonable to assume that if a prototype were declared with symbolic names which are
inconsistent with the function's definition, it is quite reasonable to expect, if not desire, warning.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19994


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c/19994] warn on parameter name mismatch
  2005-02-16 11:10 [Bug c/19994] New: warn on parameter name mismatch cyeoh at samba dot org
                   ` (4 preceding siblings ...)
  2005-02-16 17:02 ` schlie at comcast dot net
@ 2005-02-16 18:04 ` joseph at codesourcery dot com
  2005-06-19 22:55 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: joseph at codesourcery dot com @ 2005-02-16 18:04 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From joseph at codesourcery dot com  2005-02-16 13:35 -------
Subject: Re:  warn on parameter name mismatch

On Wed, 16 Feb 2005, cyeoh at samba dot org wrote:

> I think it would be fairly unusual that you would want the prototype parameter
> names to not match the definition. It wouldn't have to warn if the parameter
> names in the prototype were deliberately omitted.

I think it's quite usual for a header to use a parameter name in a 
reserved namespace (whether the implementation namespace as in glibc 
headers, or beginning with a prefix reserved by a library).  In such a 
case, the library implementation is likely to use a shorter more 
convenient name for the parameter.



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19994


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c/19994] warn on parameter name mismatch
  2005-02-16 11:10 [Bug c/19994] New: warn on parameter name mismatch cyeoh at samba dot org
                   ` (5 preceding siblings ...)
  2005-02-16 18:04 ` joseph at codesourcery dot com
@ 2005-06-19 22:55 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-06-19 22:55 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-06-19 22:55 -------
Hmm, as JSM replied, this is not something which is useful for a lot of code and would cause too many 
false warnings so closing as "won't fix".

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |WONTFIX


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19994


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-06-19 22:55 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-16 11:10 [Bug c/19994] New: warn on parameter name mismatch cyeoh at samba dot org
2005-02-16 11:13 ` [Bug c/19994] " pinskia at gcc dot gnu dot org
2005-02-16 15:16 ` cyeoh at samba dot org
2005-02-16 15:27 ` pinskia at gcc dot gnu dot org
2005-02-16 16:30 ` schlie at comcast dot net
2005-02-16 17:02 ` schlie at comcast dot net
2005-02-16 18:04 ` joseph at codesourcery dot com
2005-06-19 22:55 ` pinskia at gcc dot gnu dot org

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).