From: markbc@bnr.ca (Mark Batten-Carew)
Subject: DEC Alpha OSF1 CXX bug? Or pilot error? HELP PLEASE!
Date: 24 Nov 1994 17:49:20 GMT [thread overview]
Message-ID: <3b2jn0$m0@bcarh8ab.bnr.ca> (raw)
I am porting unix code to a Dec Alpha 3000/800 (OFS1 V3.0 347 alpha).
(The unix code currently runs on HP 9000/720 (HP-UX 9.03) and SunOS 4.1.3.)
The code is a mix of C++ and C routines which are compiled with
DEC's cxx and cc, respectively.
The C code contains two routines which use variable argument lists.
I have discovered that after calling one of these routines from
a CXX routine, the last named parameter is garbage. The same thing
happens if the C, variable arg list, routine is converted to C++.
Barring typos, here is sample code which demonstrates the problem:
--------------------- cut here and save to test.cxx -------
extern "C" {
int viewparms ( char *p1, char *p2, ... );
}
main()
{
char *p1 = "I am p1";
char *p2 = "{";
char *p3 = "}";
char *p4 = ";";
viewparms( p1, p2, p3, p4 );
return(0);
}
------------------------------- end of test.cxx -----------
--------------------- cut here and save to var.c ----------
#include <stdarg.h>
/* VARARGS */
int viewparms( char *p1, char *p2, ... )
{
va_list ap;
char *p3;
char *p4;
va_start( ap, p2 );
p3 = va_arg( ap, char * );
p4 = va_arg( ap, char * );
va_end( pa );
return( 0 );
}
------------------------------- end of var.c --------------
--------------------- cut here and save to makefile -------
test: test.cxx var.o
cxx -O0 -g1 -o test test.cxx var.o
var.o: var.c
cc -O0 -g1 -c var.c
----------------------------- end of makefile -------------
Instructions:
1. Execute: make test
2. Run "test" under a debugger (I used DECladebug).
3. "step" to the viewparms call in main and
note that all 4 parms are reasonable values.
4. "step" into viewparms and note that at least p2 is garbage.
p1 may point to a blank string, too.
Comments:
I have played with the compiler options (various -O and -g values),
changed var.c to var.cxx (then compiling with cxx, of course),
changed "stdarg.h" to "varargs.h" (although The Annotated C++
Reference Manual says not to), tried c89 instead of cc, and so on.
The relevent section of The A.R.M. is Section 8.3, page 146.
Question:
Have I done something wrong or is this just a DEC C++ bug?
Any work-around other than eliminating all variable argument calls?
Thanks for any help,
Mark Batten-Carew Northern Telecom Secure Networks
markbc@entrust.com Entrust Project
(613) 765-3477
--
Mark Batten-Carew markbc@entrust.com (work) mark@netpart.com (home)
Please consider the above text fully disclaimed.
next reply other threads:[~1994-11-24 17:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1994-11-24 17:49 Mark Batten-Carew [this message]
1994-11-25 19:33 ` DEC Alpha OSF1 CXX bug? Or pilot error? HELP PLEASE! Mark Batten-Carew
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox