This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
RE: Remove noreturn attribute for __assert_func on embedded build
- From: "Schwarz, Konrad" <konrad dot schwarz at siemens dot com>
- To: PaweÅ <pawelwod at wp dot pl>, "newlib at sourceware dot org" <newlib at sourceware dot org>
- Date: Thu, 6 Feb 2014 10:11:21 +0000
- Subject: RE: Remove noreturn attribute for __assert_func on embedded build
- Authentication-results: sourceware.org; auth=none
- References: <52F33770 dot 9080208 at wp dot pl>
> From: newlib-owner@sourceware.org [mailto:newlib-owner@sourceware.org]
> On Behalf Of Pawel
> Subject: Remove noreturn attribute for __assert_func on embedded build
> On my Cortex M I implemented simple __assert_func() as bellow
>
> void __assert_func(const char *_file, int _line, const char *_func,
> const char *_expr ) {
> (void)_file;
> (void)_line;
> (void)_func;
> (void)_expr;
> volatile int loop = 1;
> __asm volatile ("bkpt 0");
> do { ; } while( loop );
> }
>
> And when some assert expression fails I get debbuger attentions. After
> program stops I can return from this function. This is handy when
> assert fails in ISR but I have spotted that sometimes debuger shows
> broken backtrace.
> I had replaced assert() with
> if( !( ... ) )
> __asm volatile ("bkpt 0");
>
> and this works so I suppose that noreturn attribute is a problem.
The whole point of the noreturn attribute is to reduce the amount of
code produced and therefore be used only on functions that do not return.
If your __assert_func() returns, obviously it must not be declared
nonreturn. But this is your private change, and should not be merged
into Newlib, because then everyone else suffers from increased code
size.
What is non-obvious about this?