Bug 136120
Summary: | g++ generates incorrect code for aliased pointer assignments in c++ | ||
---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Dr Thomas Conway <drtomc> |
Component: | gcc | Assignee: | Jakub Jelinek <jakub> |
Status: | CLOSED NOTABUG | QA Contact: | |
Severity: | medium | Docs Contact: | |
Priority: | medium | ||
Version: | 3 | CC: | jason, oliva |
Target Milestone: | --- | ||
Target Release: | --- | ||
Hardware: | i686 | ||
OS: | Linux | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | Bug Fix | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2004-10-18 08:44:16 UTC | Type: | --- |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
Dr Thomas Conway
2004-10-18 02:09:14 UTC
The reinterpret_cast is exactly what you shouldn't be doing, see info gcc on -fstrict-aliasing, at least IMHO. ISO C++, 3.10#15 says: If a program attempts to access the stored value of an object through an lvalue of other than one of the following types the behaviour is undefined: - the dynamic type of the object, - a cv-qualified version of the dynamic type of the object, - a type that is the signed or unsigned type corresponding to the dynamic type of the object, - a type that is the signed or unsigned type corresponding to a cv-qualified version of the dynamic type of the object, - an aggregate or union type that includes one of the aforementioned types among its members (including, recursively, a member of a subaggregate or contained union) - a type that is a (possibly cv-qualified) base class type of the dynamic type of the object, - a char or unsigned char type The dynamic type of the object keys[i] is Key, and long certainly is not one of the types mentioned above, so IMHO what you are seeing is perfectly fine behaviour. |