Bug 1803333
Summary: | Regression in -Wnarrowing on 32bit (GCC10) | ||
---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Igor Raits <igor.raits> |
Component: | gcc | Assignee: | Jakub Jelinek <jakub> |
Status: | CLOSED NOTABUG | QA Contact: | Fedora Extras Quality Assurance <extras-qa> |
Severity: | unspecified | Docs Contact: | |
Priority: | unspecified | ||
Version: | rawhide | CC: | aoliva, avi.kivity, dmalcolm, fweimer, jakub, jwakely, law, mpolacek, msebor, nickc, sipoyare |
Target Milestone: | --- | Keywords: | Regression |
Target Release: | --- | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | If docs needed, set a value | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2020-02-15 10:32:45 UTC | Type: | Bug |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
Igor Raits
2020-02-15 09:58:20 UTC
Not a compiler bug. The C++ standard requires this to be diagnosed. That value cannot be converted to an int without changing its value. If you want the int value corresponding to that bit pattern, you need to use (int)0xFF534D42. If the switch is meant to be using unsigned, cast the switch expression to unsigned int (as suggested in the github issue). Adding a u suffix makes no difference because the type is already unsigned int, because the value 0xFF534D42 is too large for int. The problem is that the switch expression is an int, so any case which can't be represented as an int is ill-formed. (In reply to Jonathan Wakely from comment #1) > Not a compiler bug. The C++ standard requires this to be diagnosed. > > That value cannot be converted to an int without changing its value. If you > want the int value corresponding to that bit pattern, you need to use > (int)0xFF534D42. If the switch is meant to be using unsigned, cast the > switch expression to unsigned int (as suggested in the github issue). > > Adding a u suffix makes no difference because the type is already unsigned > int, because the value 0xFF534D42 is too large for int. The problem is that > the switch expression is an int, so any case which can't be represented as > an int is ill-formed. Hi Jonathan, thanks for the reply! So since the fix (casting the switch expression) is correct (I assume), I'll close this bug. |