* DEC Alpha OSF1 CXX bug? Or pilot error? HELP PLEASE!
@ 1994-11-24 17:49 Mark Batten-Carew
1994-11-25 19:33 ` Mark Batten-Carew
0 siblings, 1 reply; 2+ messages in thread
From: Mark Batten-Carew @ 1994-11-24 17:49 UTC (permalink / 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.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: DEC Alpha OSF1 CXX bug? Or pilot error? HELP PLEASE!
1994-11-24 17:49 DEC Alpha OSF1 CXX bug? Or pilot error? HELP PLEASE! Mark Batten-Carew
@ 1994-11-25 19:33 ` Mark Batten-Carew
0 siblings, 0 replies; 2+ messages in thread
From: Mark Batten-Carew @ 1994-11-25 19:33 UTC (permalink / raw)
It turns out that my code is correct, but the problem is in the
debugger, not the compiler. If you add a new subroutine call in
viewparms which takes 4 fixed parms, pass the 4 viewparms parms
into it, step into it, and look at the 4 parameter values,
all 4 parms are fine.
Thanks to:
Burkhard Neidecker-Lutz
GLASS Project, CEC Karlsruhe
Advanced Technology Group, Digital Equipment Corporation
for this information,
Mark Batten-Carew
markbc@entrust.com
--
Mark Batten-Carew markbc@entrust.com (work) mark@netpart.com (home)
Please consider the above text fully disclaimed.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1994-11-25 19:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1994-11-24 17:49 DEC Alpha OSF1 CXX bug? Or pilot error? HELP PLEASE! Mark Batten-Carew
1994-11-25 19:33 ` Mark Batten-Carew
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox