From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96079079016103.tru64-unix-managers.marc@archive.invalid> From: "Rustam T. Usmanov" Date: Wed, 13 Oct 1999 13:46:12 +0000 To: tru64-unix-managers Subject: Q: DIGITAL C++ bug dereferencing complex array elements? X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96079079016103 Dear managers, I get an unexpected result running the following program on AlphaServer 400/DU 4.0d/Patch kit 4 compiled with DIGITAL C++ V6.0-006: --------------------------------------- #include #include #include #include typedef struct param { int *num; } Param; main() { Param d[14]; d[7].num=(int *)malloc(sizeof(int)); memset(d[7].num, 0, sizeof(int)); printf("Before: %d\n", *d[7].num); *d[7].num=2; assert(*d[7].num==2); printf("After: %d\n", *d[7].num); return 0; } --------------------------------------- The output is: Before: 0 Assertion failed: *d[7].num==2, file test.cxx, line 18 IOT/Abort trap In other words I can't assign the value to array element member dereferencing it. When I run this program compiled with C compiler it works as it should: Before: 0 After: 2 So my questions: Is this a fault in cxx compiler? Are there any ways to resolve this problem? Thanks in advance for any info. Rustam -- Rustam Usmanov, systems engineer Open Library Systems Center, St.Petersburg State Technical University Address: 29, Politekhnitcheskaya str., St.Petersburg, 195251, Russia Tel/fax: +7(812)-552-7654