tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
* SUMMARY: DIGITAL C++ bug dereferencing complex array elements?
@ 1999-11-04  9:41 Rustam T. Usmanov
  0 siblings, 0 replies; only message in thread
From: Rustam T. Usmanov @ 1999-11-04  9:41 UTC (permalink / raw)
  To: tru64-unix-managers

The solution is to use newer version of compiler.

Thanks to:

Ed Bolson <bolson@u.washington.edu>,
"Daniel S. Riley" <dsr@mail.lns.cornell.edu>.

Thay said that following versions produce correct results:
DIGITAL C++ V6.0-021 on DIGITAL UNIX V4.0 (Rev. 878),
Compaq C++ V6.2-024 for Digital UNIX V4.0D  (Rev. 878)

I tried Compaq C++ V6.2-033 for Digital UNIX V4.0D  (Rev. 878) - works
fine.

--------------------------------------------------------------------
Original message:

From rustam@ruslan.ru Thu Nov  4 11:56:11 1999
Date: Wed, 13 Oct 1999 17:46:12 +0400 (MSK)
From: "Rustam T. Usmanov" <rustam@ruslan.ru>
To: tru64-unix-managers@ornl.gov
Subject: Q: DIGITAL C++ bug dereferencing complex array elements?
Followup-To: poster

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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>

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              <rustam@unilib.neva.ru>
Open Library Systems Center, St.Petersburg State Technical University
Address:  29, Politekhnitcheskaya str., St.Petersburg, 195251, Russia
Tel/fax: +7(812)-552-7654           <http://www.unilib.neva.ru/olsc/>

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1999-11-04  9:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-11-04  9:41 SUMMARY: DIGITAL C++ bug dereferencing complex array elements? Rustam T. Usmanov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox