Bug 20021 - warning behavior depends on textual format of literal constant
Summary: warning behavior depends on textual format of literal constant
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.0
: P2 normal
Target Milestone: 4.1.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-17 08:46 UTC by Ivan Godard
Modified: 2006-01-29 00:08 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
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 Ivan Godard 2005-02-17 08:46:06 UTC
in:
#include <cstddef>

static const signed char lwb = 0x80;
static const signed char lwba = -128;
static const signed char upb = 127;
static const size_t cnta = upb - lwba;
static const size_t cnt = upb - lwb;

int main() {
    return 0;
    }

the two variables lwb and lwba are of identical type and numeric value. However, 
the compiler gives:
~/ootbc/common/src$ g++ foo.cc
foo.cc:7: warning: integer overflow in expression

i.e. only warning on the use of lwb (reordering does not change this). It should 
warn on both or (correctly) neither.

This bug is related to bug #20019
Comment 1 Andrew Pinski 2005-11-02 20:01:41 UTC
This does not warn for me on the mainline.
Comment 2 Andrew Pinski 2006-01-29 00:08:36 UTC
Fixed in 4.1.0 and above.