This is the mail archive of the mailing list for the newlib project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Remove noreturn attribute for __assert_func on embedded build

> From: []
> 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

What is non-obvious about this?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]