发出警告和编译与警告 - 错误违反合规性? [英] Issue warning and compiling with warnings-as-errors violates compliance?

查看:140
本文介绍了发出警告和编译与警告 - 错误违反合规性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题(单行评论延续)让我想知道编译器合规性和警告消息,特别是在许多编译器中具有警告错误功能。

My question (Single line comment continuation) got me wondering about compiler compliance and warning messages, particularly with warnings-as-error feature in many compilers.

从C ++规范,§1.4.2.1说明:

From the C++ spec, § 1.4.2.1 states:


如果程序没有违反本国际标准中的规则,合格的实施应在其资源限制内接受并正确执行该程序。
If a program contains no violations of the rules in this International Standard, a conforming implementation shall, within its resource limits, accept and correctly execute that program.

如果技术上符合标准的代码(如我的链接问题)发出警告消息,即使我特别要求警告(再次,在我的例子中,如果我使用 -Wcomments 与gcc),并使用警告错误( -Werror ),程序将无法编译。我意识到这是相当钝,因为我可以解决这个问题在几个方面。

If a warning message is issued for code which technically conforms to the standard (as in my linked question), even if I specifically asked for a warning to be issued (again, in my example if I used -Wcomments with gcc), and I use warning-as-errors (-Werror), the program will not compile. I realize that this is rather obtuse, given that I could workaround the issue in several ways. However, given the quote, is this a violation of the standard which is generally permitted, or is somehow otherwise explicitly allowed?

推荐答案

这是违反通常允许的标准,还是以其他方式明确允许的?是的,如果你告诉实现不符合标准(例如,通过请求错误的格式良好的代码结构),那么它的行为将不符合。

Yes, if you tell the implementation not to conform with the standard (for example, by requesting errors for well-formed code constructs), then its behaviour won't be conforming.

这篇关于发出警告和编译与警告 - 错误违反合规性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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