本文介绍了约束违规 - 什么时候?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,


我想打开另一个话题,试图澄清我今天上一篇文章中提出的疑问。

printf(%d%d%d)''。


阅读标准,我找不到明确的定义

是什么约束违规。


重复引用:

3.8

1约束

限制,或者是句法或语义,通过它来解释语言元素的阐述


据我所知,约束是任何明确的语法或语义规则。 br />

仍然,i = i ++;不是约束违规。


为什么?该标准清楚地表明,在单个序列点内,变量不能比一次修改更多

。上述代码

修改了两次。这不是违反语义的规则吗?


P.S.阅读标准有多少我错了,这真是令人难以置信....


-

Pietro Cerutti

Dear all,

I would like to open another topic to try to clarify a doubt raised on
my previous post today with the subject ''printf("%d%d%d")''.

Reading through the standard, I cannot find a clear definition of what
is a constraint violation.

Repeating the citation:
3.8
1 constraint
restriction, either syntactic or semantic, by which the exposition
of language elements is to be interpreted

As I understand it, a constraint is any explicit syntax or semantic rule.

Still, i = i++; is not a constraint violation.

Why? The standard clearly says that a variable cannot be modified more
than once within a single sequence point. The aforementioned code
modifies i twice. Isn''t it a semantical rule being violated?

P.S. It''s incredible how many things I get wrong reading the standard....

--
Pietro Cerutti

推荐答案



来自n1256.pdf


4.一致性


1在本国际标准中,??将??在实现或程序中被解释为

要求;相反,??应该没有?b $ b不是??被解释为禁止。

2如果要?? ??或?? ??不会??违反了

约束之外的要求,行为未定义。未定义的行为

在本国际标准中以其他方式表示

字样的未定义行为?或遗漏任何明确的行为定义。这些

三者之间的重点没有区别;他们都描述了未定义的行为??

From n1256.pdf

4. Conformance

1 In this International Standard, ??shall?? is to be interpreted as a
requirement on an implementation or on a program; conversely, ??shall
not?? is to be interpreted as a prohibition.
2 If a ??shall?? or ??shall not?? requirement that appears outside of a
constraint is violated, the behavior is undefined. Undefined behavior
is otherwise indicated in this International Standard by the
words ??undefined behavior?? or by the omission of any explicit
definition of behavior. There is no difference in emphasis among these
three; they all describe ??behavior that is undefined??.




来自n1256.pdf


4.一致性


1在本国际标准中,??将??在实现或程序中被解释为

要求;相反,??应该没有?b $ b不是??被解释为禁止。

2如果要?? ??或?? ??不会??违反了

约束之外的要求,行为未定义。未定义的行为

在本国际标准中以其他方式表示

字样的未定义行为?或遗漏任何明确的行为定义。这些

三者之间的重点没有区别;他们都描述了未定义的行为??


From n1256.pdf

4. Conformance

1 In this International Standard, ??shall?? is to be interpreted as a
requirement on an implementation or on a program; conversely, ??shall
not?? is to be interpreted as a prohibition.
2 If a ??shall?? or ??shall not?? requirement that appears outside of a
constraint is violated, the behavior is undefined. Undefined behavior
is otherwise indicated in this International Standard by the
words ??undefined behavior?? or by the omission of any explicit
definition of behavior. There is no difference in emphasis among these
three; they all describe ??behavior that is undefined??.



太棒了,谢谢。我想我现在已经有了...


-

Pietro Cerutti

Great, thanks. I think I''ve got it now...

--
Pietro Cerutti




我同意这个描述是相当椭圆的;我从来没有能够在第二个逗号之后附加任何明确的含义。但是,

并没有丢失 -

I agree that this description is quite elliptic; I''ve never been able to
attach any clear meaning to the part after the second comma. However,
all is not lost --



无论它们在上面的定义中是什么意思,它都会从标准使用该术语的方式出现
,语法规则是

与语法约束不同,语义规则与语义约束不同。


所有你需要的确定约束的方法是查看

的标题,找到它的部分。如果该标题是约束,则

这是一个约束;否则它就是别的东西。例外:

5.1.2.2.1p2,6.10p2。


劳伦斯琼斯:如果5.1.2.2.1p2和6.10不会更加一致p2

不是这种模式的例外吗?

Whatever it is that they meant to say in the definition above, it
appears, from the way the standard uses the term, that syntax rules are
distinct from syntactic constraints, and that semantic rules are
distinct from semantic constraints.

All you have to do to identify a constraint is to look at the title of
the section where you found it. If that title is "constraints", then
it''s a constraint; otherwise it''s something else. Exception:
5.1.2.2.1p2, 6.10p2.

Lawrence Jones: wouldn''t it be more consistent if 5.1.2.2.1p2 and 6.10p2
were not exceptions to this pattern?


这篇关于约束违规 - 什么时候?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 22:31