中止()不__declspec(不返回的)在VS2010 [英] abort() is not __declspec(noreturn) in VS2010

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

问题描述

在我的VS2010副本,std​​lib.h中包含(行353-355)

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?

编辑:在VS2008中,这是相同的,但线条stdlib.h中的371-373

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

缺少不返回的标注的是引发错误C4716

另外参考:的C ++ 0x提案的<$ C标准化$ C>不返回的标注,它说,中止应随身携带它。

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

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

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

推荐答案

我想这肯定是错误的,因为不管是什么性病任务,随Visual Studio中的中止()实现永远不会中止返回。不能为SIGABRT将prevent _exit(3)被称为在中止()实现的Visual Studio年底做信号处理程序任何东西(我期待在文件abort.c,137行中随VS 2005)的来源。

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).

所以,因为__declspec(noreturn的)是一个实现的事情,因为中止的Visual Studio中的将实行永远都不会回到正常,中止()应标有__declspec(noreturn的)。

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.

我觉得你应该在 https://connect.microsoft.com/VisualStudio/ <作为一个bug报告此/ A>

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

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

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