Bug 84798 - incorrect handling of unalinged short
incorrect handling of unalinged short
Status: CLOSED NOTABUG
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
7.1
alpha Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2003-02-21 09:37 EST by Sergei Gorbatov
Modified: 2007-04-18 12:51 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-10-03 08:18:47 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
example of the wrong behavior (879 bytes, text/plain)
2003-02-21 09:41 EST, Sergei Gorbatov
no flags Details

  None (edit)
Description Sergei Gorbatov 2003-02-21 09:37:54 EST
Description of problem:
If a variable of type "short" crosses qword boundary (e.g. it's a member of 
packed structure), its value incorrectly retrieved/modified through the 
pointer.

Version-Release number of selected component (if applicable):
g++ 3.2.1

How reproducible:
always

Steps to Reproduce:
1. compile & run attached example
2.
3.
    
Actual results:
First 2 output lines shows correct behavior (direct access to the packed 
structure member, no_problem() function);
second 2 output lines shows incorrect behavior (access to the same data 
through the pointer, problem() function)

Expected results:
variable should be correctly accessed/modified through the pointer :)

Additional info:
Comment 1 Sergei Gorbatov 2003-02-21 09:41:23 EST
Created attachment 90243 [details]
example of the wrong behavior
Comment 2 Richard Henderson 2004-10-03 08:18:47 EDT
    short *pw = &ps->word;

This assignment is buggy.  You can't take the address of an element of
a packed structure and assign it to a normal "short *".

Note You need to log in before you can comment on or make changes to this bug.