[Bug c/27272] New: Strange order of components of multidimensional array pointer with the same cast

2006-04-23 Thread prog1 at yobinario dot com
char *yn;
yn = (char *) malloc (sizeof (char) * x * y);
First subroutine included with {}:
char (*pointer)[x][y] = (char (*)[x][y]) yn;
&((*pointer)[0][0]) is 0x8052100
&((*pointer)[0][1]) is 0x8052107

Second routine independent function passed as pointer yn as parameter;
char (*pointer)[x][y] = (char (*)[x][y]) yn;

In second routine the pointers only is the same if (x) y replaced with (y) and
(y) with (x)

&((*pointer)[0][0]) with pointer 0x8052100
&((*pointer)[1][0]) with pointer 0x8052107


-- 
   Summary: Strange order of components of multidimensional array
pointer with the same cast
   Product: gcc
   Version: 4.0.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: prog1 at yobinario dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27272



[Bug middle-end/27272] Strange order of components of multidimensional array pointer with the same cast

2006-04-23 Thread prog1 at yobinario dot com


--- Comment #2 from prog1 at yobinario dot com  2006-04-23 20:20 ---
Created an attachment (id=11320)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=11320&action=view)
test_code

OUTPUT:
./gcc_test
Printing matrix... 0x804a008
MATRIX [0][0] = [1] with pointer 0x804a008
MATRIX [0][1] = [2] with pointer 0x804a00f
MATRIX [0][2] = [3] with pointer 0x804a016
MATRIX [0][3] = [4] with pointer 0x804a01d
MATRIX [0][4] = [5] with pointer 0x804a024
MATRIX [0][5] = [6] with pointer 0x804a02b
MATRIX [0][6] = [7] with pointer 0x804a032
create call...
MATRIX [0][0]=[1] with pointer 0x804a008
MATRIX [0][1]=[0] with pointer 0x804a009
MATRIX [0][2]=[0] with pointer 0x804a00a
MATRIX [0][3]=[0] with pointer 0x804a00b
MATRIX [0][4]=[0] with pointer 0x804a00c
MATRIX [0][5]=[0] with pointer 0x804a00d
MATRIX [0][6]=[0] with pointer 0x804a00e
Inverse order
MATRIX [0][0]=[1] with pointer 0x804a008
MATRIX [1][0]=[2] with pointer 0x804a00f
MATRIX [2][0]=[3] with pointer 0x804a016
MATRIX [3][0]=[4] with pointer 0x804a01d
MATRIX [4][0]=[5] with pointer 0x804a024
MATRIX [5][0]=[6] with pointer 0x804a02b
MATRIX [6][0]=[7] with pointer 0x804a032
OK


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27272