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]

[Bug c/16804] New: Function pointer assignment/initialization (missing warning)


Code:

enum Moo { Baa, Oink };
static unsigned int quack (void) { return 0; }
enum Moo (*Miau) (void) = quack;

> gcc-3.4 -Wall -c ~/foo.c
> gcc-2.95.2 -Wall -c ~/foo.c
> /opt/SUNWspro/bin/cc -V -c  ~/foo.c
cc: Sun WorkShop 6 update 2 C 5.3 Patch 111679-08 2002/05/09
acomp: Sun WorkShop 6 update 2 C 5.3 Patch 111679-08 2002/05/09
"/home/welinder/foo.c", line 3: warning: initialization type mismatch
> ./check ~/foo.c
/home/welinder/foo.c:3:27: warning: incorrect type in initializer (different
base types)
/home/welinder/foo.c:3:27:    expected enum Moo ( *[addressable] [toplevel] Miau
)( ... )
/home/welinder/foo.c:3:27:    got unsigned int ( static [addressable] [toplevel]
*<noident> )( ... )

Note the "unsigned".  Without that, I do get a warning.

-- 
           Summary: Function pointer assignment/initialization (missing
                    warning)
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: terra at gnome dot org
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: sparc-sun-solaris2.8


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


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