abort()不是__declspec(noreturn)在VS2010 [英] abort() is not __declspec(noreturn) in VS2010

查看:419
本文介绍了abort()不是__declspec(noreturn)在VS2010的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在VS2010的副本中,stdlib.h包含(行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);



我很奇怪,没有 noreturn 注释在 abort()。有没有人知道这个的原因?这是一个错误吗?



编辑:在VS2008中,它是一样的,但stdlib.h的371-373行



缺少 noreturn 注释会触发错误C4716



进一步参考: C ++ 0x建议标准化 noreturn 注释,其中说 abort 应该携带它。



编辑:看起来像一堆讨论消失了一个已删除的答案,但它的要点覆盖在缺陷报告#048

解决方案

我认为这绝对是错误的,因为无论什么std强制,abort()实现与Visual Studio附带将永远不会从中止返回。你不能在SIGABRT的信号处理程序中做任何事情,这将阻止_exit(3)在Visual Studio的abort()实现结束时被调用(我正在查看文件abort.c,第137行,因为__declspec(noreturn)是一个实现事情,并且由于在Visual Studio中的abort的实现永远不会正常返回,abort()应该是标记为__declspec(noreturn)。



它的缺席是一个错误。



请在 https://connect.microsoft.com/VisualStudio/ 中将此错误报告为


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.

解决方案

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/

这篇关于abort()不是__declspec(noreturn)在VS2010的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆