Bug 84798 - incorrect handling of unalinged short
Summary: incorrect handling of unalinged short
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc
Version: 7.1
Hardware: alpha
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Brian Brock
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2003-02-21 14:37 UTC by Sergei Gorbatov
Modified: 2007-04-18 16:51 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2004-10-03 12:18:47 UTC
Embargoed:


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

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 *".


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