public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/40325]  New: C frontend permits setting a function pointer to a function with different parameter type
@ 2009-06-01 20:34 ian at airs dot com
  2009-06-01 20:40 ` [Bug c/40325] " pinskia at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: ian at airs dot com @ 2009-06-01 20:34 UTC (permalink / raw)
  To: gcc-bugs

This C program is compiled with no warning or error by mainline.

enum E { A };
void foo(unsigned int);
void (*pfn)(enum E) = foo;

My reading of ISO C says that these function pointers are not compatible types.
 I think the compiler should report something like

warning: initialization from incompatible pointer type


-- 
           Summary: C frontend permits setting a function pointer to a
                    function with different parameter type
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ian at airs dot com


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


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

* [Bug c/40325] C frontend permits setting a function pointer to a function with different parameter type
  2009-06-01 20:34 [Bug c/40325] New: C frontend permits setting a function pointer to a function with different parameter type ian at airs dot com
@ 2009-06-01 20:40 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-06-01 20:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2009-06-01 20:40 -------
Actually I think they are compatible.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=6024#c3 explains why they are. 
The reason why they are compatible is explicitly explained in 6.7.2.2#4 (which
specifies that enumerated types are  compatible with char or a signed or
unsigned integer type).

Since enum E is compatible with unsigned int, the function pointer is
compatible as the functions arguments are compatible.


-- 

pinskia at gcc dot gnu dot org changed:

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


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


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

end of thread, other threads:[~2009-06-01 20:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-01 20:34 [Bug c/40325] New: C frontend permits setting a function pointer to a function with different parameter type ian at airs dot com
2009-06-01 20:40 ` [Bug c/40325] " 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).