Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

abort() is not __declspec(noreturn) in VS2010

In my copy of VS2010, stdlib.h contains (lines 353-355)

_CRTIMP __declspec(noreturn) void __cdecl exit(_In_ int _Code);
_CRTIMP __declspec(noreturn) void __cdecl _exit(_In_ int _Code);
_CRTIMP void __cdecl abort(void);

I find it strange that there's no noreturn annotation on abort(). Does anyone know a reason for this? Is it a bug?

EDIT: In VS2008, it's the same, but lines 371-373 of stdlib.h

The lack of the noreturn annotation is triggering error C4716.

Further reference: C++0x proposal for standardization of the noreturn annotation, which says that abort should carry it.

EDIT: Looks like a bunch of discussion disappeared with a deleted answer, but the gist of it is covered in Defect Report #048.

like image 598
Ben Voigt Avatar asked Aug 25 '10 19:08

Ben Voigt


1 Answers

I think this is definitely wrong because regardless of what the std mandates, the abort() implementation shipped with Visual Studio will never return from abort. You cannot do anything in the signal handler for SIGABRT that will prevent _exit(3) being called at the end of the abort() implementation of Visual Studio (I'm looking at the file abort.c, line 137 in the sources shipped with VS 2005).

So since __declspec(noreturn) is an implementation thing and since the implemenation of abort in Visual Studio will never, ever return normally, abort() should be tagged with __declspec(noreturn).

It follows that it's absence is a bug.

I think you should report this as a bug at https://connect.microsoft.com/VisualStudio/

like image 110
Martin Ba Avatar answered Nov 03 '22 04:11

Martin Ba