From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,7fc783e394bb722a,start X-Google-Attributes: gid1164f8,public X-Google-Thread: f678f,7fc783e394bb722a,start X-Google-Attributes: gidf678f,public X-Google-Thread: fee84,7fc783e394bb722a,start X-Google-Attributes: gidfee84,public X-Google-ArrivalTime: 1994-11-24 09:49:20 PST Path: nntp.gmd.de!urmel.informatik.rwth-aachen.de!newsserver.rrzn.uni-hannover.de!aix11.hrz.uni-oldenburg.de!nordwest.germany.eu.net!pophh!Germany.EU.net!howland.reston.ans.net!torn!nott!bcarh189.bnr.ca!bcarh8ab.bnr.ca!markbc From: markbc@bnr.ca (Mark Batten-Carew) Newsgroups: comp.sys.dec,comp.unix.osf.misc,comp.unix.osf.osf1 Subject: DEC Alpha OSF1 CXX bug? Or pilot error? HELP PLEASE! Followup-To: comp.sys.dec Date: 24 Nov 1994 17:49:20 GMT Organization: Bell-Northern Research Ltd. Message-ID: <3b2jn0$m0@bcarh8ab.bnr.ca> Reply-To: markbc@bnr.ca NNTP-Posting-Host: bcarh640.bnr.ca Keywords: varargs.h stdarg.h va_arg cxx osf1 alpha dec Originator: markbc@bcarh640 Xref: nntp.gmd.de comp.sys.dec:20028 comp.unix.osf.misc:2099 comp.unix.osf.osf1:6652 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 /* 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.