[Bug c/71447] New: problem with pointer arythmetic?
johannesjanssens at telenet dot be
gcc-bugzilla@gcc.gnu.org
Tue Jun 7 15:06:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71447
Bug ID: 71447
Summary: problem with pointer arythmetic?
Product: gcc
Version: 4.9.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: johannesjanssens at telenet dot be
Target Milestone: ---
code snippet :
--------------
typedef struct HstruWA *WA;
typedef struct HstruWA{ //NEWHANDLE(WA)
int qt;
int *ofs;
char *cnttypes;
char *record;
} externWA;
typedef struct internWA{
char **ptArray;
int recsize;
WA wa;
int qt_added;
ADDED *added; //chain
} internWA;
typedef internWA *IWA;
/*
#define mDATAOFFSET(QT)
(((QT+1)*sizeof(int))+(QT*sizeof(char)))
#define mOFFSARRAY(_Record) ((int*)(_Record+sizeof(int)))
#define mCNTSARRAY(_Record,_QT) ((char*)(_Record+sizeof(int)*(_QT+1)))
*/
iwa->wa = ram.sf_alloc("wa1",iwa->wa, mDATAOFFSET(qt) + bufsize );
iwa->wa->qt=qt;
int *k = mOFFSARRAY(iwa->wa);
iwa->wa->ofs=mOFFSARRAY(iwa->wa);
The problem :
-------------
assigning the same value to the variable k gives a different result from
assigning it to iwa->wa->ofs. Both are of type *int
in gdb:
-------
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff79cb01b in new_from_stringarray (s=0x4021c4 "Janssens,Johannes",
splitbalk=44 ',') at
/home/wannes/ontwikkeling/projecten/libwgpeUtil/wgpArr.c:154
154 iwa->wa->ofs[idx]=thislen;
(gdb) p k
$8 = (int *) 0x605260
(gdb) p iwa->wa->ofs
$9 = (int *) 0x614a000000605260
(gdb)
More information about the Gcc-bugs
mailing list