Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Mon, 29 Aug 2016 20:05:00 -0400
From: Assaf Gordon <>
Subject: assert_fail without Noreturn


It seems "assert_fail()"  does not have a "noreturn" attribute - it was removed in this commit:

   commit 2c1f8fd5da3306fd7c8a2267467e44eb61f12dd4
   Author: rofl0r <>
   Date:   Tue Jan 1 07:59:11 2013 +0100

   __assert_fail(): remove _Noreturn, to get proper stack traces

   for _Noreturn functions, gcc generates code that trashes the
   stack frame, and so it makes it impossible to inspect the causes
   of an assert error in gdb.

   abort() is not affected (i have not yet investigated why).

However, in recent GCC versions (at least 5.2.0) this causes a compiler warning (or error with -Werror).

A contrived example:

   $ cat 2.c

   #include <assert.h>
   #include <stdio.h>

   FILE* foo (int i)
     FILE *f;
     if (i>0)
       f = fopen("","r");
     return f;

   $ musl-gcc -O2 -Wall -Wextra -c 2.c
   2.c: In function ‘foo’:
   2.c:12:11: error: ‘f’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
       return f;
   cc1: some warnings being treated as errors

Using 'gcc' instead of 'musl-gcc' shows no warnings.

The compiler is:

   $ musl-gcc -v
   Using built-in specs.
   Reading specs from /usr/local/musl/lib/musl-gcc.specs
   rename spec cpp_options to old_cpp_options
   Target: x86_64-unknown-linux-gnu
   Configured with: ../gcc-5.2.0/configure --enable-languages=c,c++
   Thread model: posix
   gcc version 5.2.0 (GCC)

Using musk-libc version 1.1.15 from tarball.

Perhaps putting "_Noreturn" in "assert_fail" can be reconsidered ?
Or perhaps there's another way to avoid this warning ?

- assaf

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.