Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 84798 - incorrect handling of unalinged short
Summary: incorrect handling of unalinged short
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc
Version: 7.1
Hardware: alpha
OS: Linux
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Brian Brock
Depends On:
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:
Last Closed: 2004-10-03 12:18:47 UTC

Attachments (Terms of Use)
example of the wrong behavior (deleted)
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 

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

How reproducible:

Steps to Reproduce:
1. compile & run attached example
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.