Bug 20535 - add warning or error if storage size mismatch
Summary: add warning or error if storage size mismatch
Status: RESOLVED DUPLICATE of bug 9072
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.1.0
: P2 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-18 17:31 UTC by olh
Modified: 2005-07-23 22:49 UTC (History)
2 users (show)

See Also:
Host: powerpc-linux
Target: powerpc-linux
Build: powerpc-linux
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description olh 2005-03-18 17:31:09 UTC
We see more and more code like this, in this case e2fsprogs blkid:

char c;
c=getopt(...)

getopt returns an int, and so does getc.
But gcc stores the thing in something that cant hold the return type.

It should warn with an obvious message, or even error out.
Comment 1 olh 2005-03-18 17:32:33 UTC
just checked, gcc4 accepts it (blkid.c) as well.
Comment 2 Joseph S. Myers 2005-03-19 13:34:39 UTC
What you want is a better -Wconversion, "warn for any implicit conversion that
may change a value"; see bug 9072 (and also bug 6614).  Bug 9072 effectively
tracks the need for a better -Wconversion while bug 6614 deals with the
particularly unintuitive parts of the present -Wconversion.  Such warnings
would not however be appropriate to be on by default or to be included in -Wall
or -Wextra; they'd remain a separate -Wconversion flag.


*** This bug has been marked as a duplicate of 9072 ***