From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a0e076952eca80d4 X-Google-Attributes: gid103376,public From: jmccall4@sl0270.srl.ford.com (James McCallum) Subject: Re: Ada and C++ asserts. Date: 1996/07/17 Message-ID: <4sirua$18p@fiesta.srl.ford.com>#1/1 X-Deja-AN: 169290045 references: organization: SRL, Ford Motor Company reply-to: jmccall4@sl0270.srl.ford.com newsgroups: comp.lang.ada Date: 1996-07-17T00:00:00+00:00 List-Id: In article , nasser@apldbio.com (Nasser Abbasi) writes: > >I am trying to keep an open mind about things, but see >for yourself, a simple program to test assertions, the >Ada version works fine, the C++ core dumps after it >displays the assertion statment. > >This is on Sun Solaris 2.5, using sun CC V4.0, and >GNAT 3.05 . I might be doing something wrong in the >C++ version, [if so, please tell me what I am >doing wrong!] but I can not seem to see it. (after >all, it is just a 2 line program ! ) May be this should >win an award for the smallest C++ program to core dump :) > >ada version: >============ > [... ada version deleted ...] > > >C++ version >============ > >------------------------------------------- >#include >main() >{ >int i=0; > > assert(i == 1); > return 0; >} >------------------------------------------ > >..... now build and run > >$CC t2.cc >$a.out >Assertion failed: i == 1, file t2.cc, line 8 >Abort (core dumped) > ^^^^^^^^^^^^^ > Form the Solaris man pages assert(3C) C Library Functions assert(3C) NAME assert - verify program assertion ... DESCRIPTION This macro is useful for putting diagnostics into programs. When it is executed, if expression is false (zero), assert() prints Assertion failed: expression, file xyz, line nnn on the standard error output and aborts.... ^^^^^^ abort(3C) C Library Functions abort(3C) NAME abort - terminate the process abnormally ... NOTES Catching the signal is intended to provide the application writer with a portable means to abort processing, free from possible interference from any implementation-provided library functions. If SIGABRT is neither caught nor ignored, and the current directory is writable, a core dump may be produced. ^^^^ It looks as if the C++ version does work. :) James. -- --- James McCallum Acro Service Corp on contract to Engine and Processes Dept. Tel: +1 313 248 9017 Ford Motor Co. e-mail: external internal profs jmccall4@ford.com jmccall4@sl0270.srl jmccall4