|
Message-ID: <20160830205427.GK15995@brightrain.aerifal.cx> Date: Tue, 30 Aug 2016 16:54:28 -0400 From: Rich Felker <dalias@...c.org> To: musl@...ts.openwall.com Subject: Re: assert_fail without Noreturn On Mon, Aug 29, 2016 at 08:05:00PM -0400, Assaf Gordon wrote: > Hello, > > It seems "assert_fail()" does not have a "noreturn" attribute - it was removed in this commit: > > commit 2c1f8fd5da3306fd7c8a2267467e44eb61f12dd4 > Author: rofl0r <retnyg@....net> > 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("foo.bar","r"); > else > assert(!"error"); > 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 > COLLECT_GCC=gcc > COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/5.2.0/lto-wrapper > 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 ? I'm reverting commit 2c1f8fd5da3306fd7c8a2267467e44eb61f12dd4 based on discussion with the patch contributor and testing. Further details will be in the commit message. Thanks! Rich
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.