Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

assert

2 views
Skip to first unread message

sam

unread,
Feb 13, 2001, 7:44:04 PM2/13/01
to
Is the behaviour of macro assert in the header file assert.h
implementation-defined, ie will the system always print an error message
when the value of the expression tested is 0 ?

Thank you


Dan Pop

unread,
Feb 13, 2001, 7:27:31 AM2/13/01
to

The error message on stderr and the program termination via an abort()
call are guaranteed.

What is implementation-defined is the format of the error message
and the effect of calling abort() (beyond the fact that the program will
be terminated).

Dan
--
Dan Pop
CERN, IT Division
Email: Dan...@cern.ch
Mail: CERN - IT, Bat. 31 1-014, CH-1211 Geneve 23, Switzerland

Richard Bos

unread,
Feb 13, 2001, 7:51:26 AM2/13/01
to
"sam" <s...@singnet.com.sg> wrote:

What it writes exactly is implementation-defined. That it does write
something, including file name, line number, and the assert()ed
expression, and then calls abort(), is ISO-defined (to coin a term).

Richard

alex_vinokur

unread,
Feb 13, 2001, 9:30:40 AM2/13/01
to
> In <3a891e8d$1...@news.starhub.net.sg> "sam" <s...@singnet.com.sg> writes:
>
> >Is the behaviour of macro assert in the header file assert.h
> >implementation-defined, ie will the system always print an error message
> >when the value of the expression tested is 0 ?
>
> The error message on stderr and the program termination via an abort()
> call are guaranteed.

Regarding abort () : not always.
In Diab Data D-CC Optimizing C compiler (using in pSOS)
the program doesn't terminate its running.

P.S. That behavior is not ANSI C one.

>
> What is implementation-defined is the format of the error message
> and the effect of calling abort() (beyond the fact that the program will
> be terminated).
>
> Dan
> --
> Dan Pop
> CERN, IT Division
> Email: Dan...@cern.ch
> Mail: CERN - IT, Bat. 31 1-014, CH-1211 Geneve 23, Switzerland

============================
Alex Vinokur
mailto:ale...@bigfoot.com
http://go.to/alexv_math
============================


==================================
Posted via http://nodevice.com
Linux Programmer's Site

Ben Pfaff

unread,
Feb 13, 2001, 10:23:03 AM2/13/01
to
Alex Vinokur writes:

> > In <3a891e8d$1...@news.starhub.net.sg> "sam" <s...@singnet.com.sg> writes:
> >
> > >Is the behaviour of macro assert in the header file assert.h
> > >implementation-defined, ie will the system always print an error message
> > >when the value of the expression tested is 0 ?
> >
> > The error message on stderr and the program termination via an abort()
> > call are guaranteed.
>
> Regarding abort () : not always.
> In Diab Data D-CC Optimizing C compiler (using in pSOS)
> the program doesn't terminate its running.
>
> P.S. That behavior is not ANSI C one.

Then what is the point of bringing it up in an ANSI C context?
--
"You call this a *C* question? What the hell are you smoking?" --Kaz

Dan Pop

unread,
Feb 13, 2001, 11:05:39 AM2/13/01
to
In <96bge...@news1.newsguy.com> Alex Vinokur writes:

>> In <3a891e8d$1...@news.starhub.net.sg> "sam" <s...@singnet.com.sg> writes:
>>
>> >Is the behaviour of macro assert in the header file assert.h
>> >implementation-defined, ie will the system always print an error message
>> >when the value of the expression tested is 0 ?
>>
>> The error message on stderr and the program termination via an abort()
>> call are guaranteed.
>
>Regarding abort () : not always.

Always, in hosted C implementations.

>In Diab Data D-CC Optimizing C compiler (using in pSOS)
> the program doesn't terminate its running.

Then, Diab Data D-CC is not a hosted C implementation.

>P.S. That behavior is not ANSI C one.

It actually is, if the implementation doesn't claim to be a hosted C
implementation. A freestanding implementation can attach any meaning
it wants to the abort() function, if it chooses to provide one at all.

alex_vinokur

unread,
Feb 15, 2001, 12:52:30 AM2/15/01
to
> In <96bge...@news1.newsguy.com> Alex Vinokur writes:
>
> >> In <3a891e8d$1...@news.starhub.net.sg> "sam" <s...@singnet.com.sg> writes:
> >>
> >> >Is the behaviour of macro assert in the header file assert.h
> >> >implementation-defined, ie will the system always print an error message
> >> >when the value of the expression tested is 0 ?
> >>
> >> The error message on stderr and the program termination via an abort()
> >> call are guaranteed.
> >
> >Regarding abort () : not always.
>
> Always, in hosted C implementations.
>
> >In Diab Data D-CC Optimizing C compiler (using in pSOS)
> > the program doesn't terminate its running.
>
> Then, Diab Data D-CC is not a hosted C implementation.
>
> >P.S. That behavior is not ANSI C one.
>
> It actually is, if the implementation doesn't claim to be a hosted C
> implementation. A freestanding implementation can attach any meaning
> it wants to the abort() function, if it chooses to provide one at all.

Thanks for this information.
How can we know if specific compiler is a freestanding implementation?
P.S. I didn't find relevant information in Diab compiler description.
Must this information be in compiler description? (Does ANSI C require it?)

>
> Dan
> --
> Dan Pop
> CERN, IT Division
> Email: Dan...@cern.ch
> Mail: CERN - IT, Bat. 31 1-014, CH-1211 Geneve 23, Switzerland


Alex Vinokur

0 new messages