Talk:One Definition Rule

Latest comment: 4 years ago by BernardoSulzbach in topic First Paragraph

First Paragraph

edit

The first paragraph of this page is "ODR is important in C++". This is not a good description of this page. Wikipedia's Wikipedia:Manual of Style/Lead section page of the manual gives some guidelines about it. The first paragraph should be an introduction to the article and a brief summary.

I'm still trying to understand ODR, so I'm not the best person to make this edit.

Well noticed. I tried to summarize the core of the rule in the lead. BernardoSulzbach (talk) 13:10, 28 November 2019 (UTC)Reply

Untitled

edit

What's the problem with the last snippet? The statement is incorrect: that code compiles even in pre-C++0x compliant compilers. Dgutson (talk) —Preceding undated comment added 19:38, 15 April 2009 (UTC).Reply

It does, but according to the standard it is ill-formed. The reason for this is the wording of [basic.defs.odr]/2: "An expression is potentially evaluated unless it appears where an integral constant expression is required ... An object or non-overloaded function is used if its name appears in a potentially-evaluated expression". According to this, the static data member is clearly used in the example. Furthermore, "Every program shall contain exactly one definition of every non-inline function or object that is used in that program; no diagnostic required", in essence, even if it is ill-formed, the compiler does not have to warn about it, but the resulting program has undefined behaviour. decltype (talk) 20:25, 15 April 2009 (UTC)Reply