Bug 84798

Summary: incorrect handling of unalinged short
Product: [Retired] Red Hat Linux Reporter: Sergei Gorbatov <sergei.gorbatov>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED NOTABUG QA Contact: Brian Brock <bbrock>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.1   
Target Milestone: ---   
Target Release: ---   
Hardware: alpha   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-10-03 12:18:47 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:
Attachments:
Description Flags
example of the wrong behavior none

Description Sergei Gorbatov 2003-02-21 14:37:54 UTC
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 14:41:23 UTC
Created attachment 90243 [details]
example of the wrong behavior

Comment 2 Richard Henderson 2004-10-03 12:18:47 UTC
    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 *".