public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/16804] New: Function pointer assignment/initialization (missing warning)
@ 2004-07-28 17:18 terra at gnome dot org
  2004-07-28 17:39 ` [Bug c/16804] " bangerth at dealii dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: terra at gnome dot org @ 2004-07-28 17:18 UTC (permalink / raw)
  To: gcc-bugs

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


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

* [Bug c/16804] Function pointer assignment/initialization (missing warning)
  2004-07-28 17:18 [Bug c/16804] New: Function pointer assignment/initialization (missing warning) terra at gnome dot org
@ 2004-07-28 17:39 ` bangerth at dealii dot org
  2004-07-28 18:23 ` jsm at polyomino dot org dot uk
  2004-07-28 18:51 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 6+ messages in thread
From: bangerth at dealii dot org @ 2004-07-28 17:39 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-07-28 17:39 -------
The code is valid C (though invalid C++). A warning may be not such a  
bad idea, though. 
 
W. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |diagnostic
   Last reconfirmed|0000-00-00 00:00:00         |2004-07-28 17:39:04
               date|                            |


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


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

* [Bug c/16804] Function pointer assignment/initialization (missing warning)
  2004-07-28 17:18 [Bug c/16804] New: Function pointer assignment/initialization (missing warning) terra at gnome dot org
  2004-07-28 17:39 ` [Bug c/16804] " bangerth at dealii dot org
@ 2004-07-28 18:23 ` jsm at polyomino dot org dot uk
  2004-07-28 18:51 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 6+ messages in thread
From: jsm at polyomino dot org dot uk @ 2004-07-28 18:23 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jsm at polyomino dot org dot uk  2004-07-28 18:23 -------
Subject: Re:  New: Function pointer assignment/initialization
 (missing warning)

On Wed, 28 Jul 2004, terra at gnome dot org wrote:

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

GCC makes enums compatible with unsigned by default if they have no
negative values.  I'm working on improving the documentation of
implementation-defined behavior, and the improved documentation mentions
this choice.



-- 


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


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

* [Bug c/16804] Function pointer assignment/initialization (missing warning)
  2004-07-28 17:18 [Bug c/16804] New: Function pointer assignment/initialization (missing warning) terra at gnome dot org
  2004-07-28 17:39 ` [Bug c/16804] " bangerth at dealii dot org
  2004-07-28 18:23 ` jsm at polyomino dot org dot uk
@ 2004-07-28 18:51 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-07-28 18:51 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-07-28 18:51 -------
The diagnostic is only for non-portable code.

-- 


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


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

* [Bug c/16804] Function pointer assignment/initialization (missing warning)
       [not found] <bug-16804-9033@http.gcc.gnu.org/bugzilla/>
  2007-01-09 15:06 ` manu at gcc dot gnu dot org
@ 2008-10-26 22:13 ` manu at gcc dot gnu dot org
  1 sibling, 0 replies; 6+ messages in thread
From: manu at gcc dot gnu dot org @ 2008-10-26 22:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from manu at gcc dot gnu dot org  2008-10-26 22:12 -------
There is no warning in GCC 4.4, not even with pedantic. Should we really try to
warn about this?


-- 


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


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

* [Bug c/16804] Function pointer assignment/initialization (missing warning)
       [not found] <bug-16804-9033@http.gcc.gnu.org/bugzilla/>
@ 2007-01-09 15:06 ` manu at gcc dot gnu dot org
  2008-10-26 22:13 ` manu at gcc dot gnu dot org
  1 sibling, 0 replies; 6+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-01-09 15:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from manu at gcc dot gnu dot org  2007-01-09 15:06 -------
Is the warning a good idea because it is a function call, so it may be a
confused call to quak, or simply because it is unsigned converted to enum ?


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu dot org


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


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

end of thread, other threads:[~2008-10-26 22:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-28 17:18 [Bug c/16804] New: Function pointer assignment/initialization (missing warning) terra at gnome dot org
2004-07-28 17:39 ` [Bug c/16804] " bangerth at dealii dot org
2004-07-28 18:23 ` jsm at polyomino dot org dot uk
2004-07-28 18:51 ` pinskia at gcc dot gnu dot org
     [not found] <bug-16804-9033@http.gcc.gnu.org/bugzilla/>
2007-01-09 15:06 ` manu at gcc dot gnu dot org
2008-10-26 22:13 ` manu 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).