Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Weird C++ Compiler Ignores Errors

Reply
Thread Tools

Weird C++ Compiler Ignores Errors

 
 
Paul Bibbings
Guest
Posts: n/a
 
      04-19-2010
Öö Tiib <(E-Mail Removed)> writes:

> On 19 apr, 20:36, Paul Bibbings <(E-Mail Removed)> wrote:
>> Öö Tiib <(E-Mail Removed)> writes:
>> > Standard contains an explicit notation that "no diagnostic is
>> > required" in 14.7.

>>
>> [Note: the reference for ISO/IEC 14882: 2003 is 14.6/7.]
>>
>> I had managed to miss the "no diagnostic required." *I am assuming that
>> the relevant section is (from 14.6/7):
>>
>> "If no valid specialization can be generated for a template
>> definition, and that template is not instantiated, the templated
>> definition is ill-formed, no diagnostic is required."

>
>
> Yes, i messed up the numbers, thanks for correcting.
>
>
>> What this leads me on to is what that actually means in terms of the
>> correctness of the program (in this instance, the program given in
>> the original post by the OP).
>>
>> 1.4/2 [intro.compliance] states:
>> "If a program contains a violation of a rule for which no
>> diagnostic is required, this International Standard places no
>> requirement on implementations with respect to that program."
>>
>> At this point the (surely necessary) `legalese' begins to escape me. To
>> my reading, there appears to be (or, at least, I hear) an implicit
>> "whatsoever" after "places no requirement." To me this appears to be
>> saying, in relation to the OP's original code, that as it was accepted
>> without diagnostic (not being required to do so), it nevertheless rendered
>> the whole program, in so doing, effectively of no concern in terms of
>> the standard; what, in my part of the world, we'd translate to "you're
>> on your own, mate. Might as well be written in Pascal, for all I care!"
>>
>> Would that be a fair reading, or is my legalese as bad as I think it
>> might be?

>
> That standardese means basically that it is possible that someone evil
> gains something from that undefined behavior. For example infects your
> computer running that program with evil .jpg and gains control over
> it. Standard has washed its hands then and also the hands of
> implementations that translated the program by standard. It is
> standards way to say that "BLA BLA NO WARRANTY BLA BLA NO
> MERCHANTABILITY BLA BLA NO PARTICULAR PURPOSE."


Now, you have brought in the term `undefined behavior'. Is that what we
have here? The relevant sections as they have been traced back from
§14.6/7 do not actually use the term.

§1.3.12 [defns.undefined] has, for undefined behavior:
"behavior, such as might arise upon use of an erroneous program
construct or erroneous data, for which this International Standard
imposes no requirements. Undefined behavior may also be expecte when
this International Standard omits the description of any explicit
definition of behavior. ..."

It certainly appears that this definition of undefined behavior uses the
same (or similar) terms to those used in §1.4/2, quoted above.

If so, the conclusion would then appears to be that, in compiling the
OP's original code, VC++ was invoking undefined behaviour and/or, at the
very least, exhibiting Standards non-compliance; that, although I was
wrong in my original analysis to suggest that "this `error' should, in
fact, be diagnosed on other grounds," it is, nonetheless, an error on
the part of VC++.

If this is how it is, does this generalize out? Do *all* uses of the
phrase "no diagnostic required" instantly impart Standard non-compliance
to the code in question, and perhaps also undefined behavior?

Regards

Paul Bibbings
 
Reply With Quote
 
 
 
 
Öö Tiib
Guest
Posts: n/a
 
      04-20-2010
On Apr 19, 11:59*pm, Paul Bibbings <(E-Mail Removed)> wrote:
> Tiib <(E-Mail Removed)> writes:
> > On 19 apr, 20:36, Paul Bibbings <(E-Mail Removed)> wrote:
> >> Tiib <(E-Mail Removed)> writes:
> >> > Standard contains an explicit notation that "no diagnostic is
> >> > required" in 14.7.

>
> >> [Note: the reference for ISO/IEC 14882: 2003 is 14.6/7.]

>
> >> I had managed to miss the "no diagnostic required." I am assuming that
> >> the relevant section is (from 14.6/7):

>
> >> * *"If no valid specialization can be generated for a template
> >> * *definition, and that template is not instantiated, the templated
> >> * *definition is ill-formed, no diagnostic is required."

>
> > Yes, i messed up the numbers, thanks for correcting.

>
> >> What this leads me on to is what that actually means in terms of the
> >> correctness of the program (in this instance, the program given in
> >> the original post by the OP).

>
> >> 1.4/2 [intro.compliance] states:
> >> * * "If a program contains a violation of a rule for which no
> >> * * diagnostic is required, this International Standard places no
> >> * * requirement on implementations with respect to that program."

>
> >> At this point the (surely necessary) `legalese' begins to escape me. To
> >> my reading, there appears to be (or, at least, I hear) an implicit
> >> "whatsoever" after "places no requirement." To me this appears to be
> >> saying, in relation to the OP's original code, that as it was accepted
> >> without diagnostic (not being required to do so), it nevertheless rendered
> >> the whole program, in so doing, effectively of no concern in terms of
> >> the standard; what, in my part of the world, we'd translate to "you're
> >> on your own, mate. Might as well be written in Pascal, for all I care!"

>
> >> Would that be a fair reading, or is my legalese as bad as I think it
> >> might be?

>
> > That standardese means basically that it is possible that someone evil
> > gains something from that undefined behavior. For example infects your
> > computer running that program with evil .jpg and gains control over
> > it. Standard has washed its hands then and also the hands of
> > implementations that translated the program by standard. It is
> > standards way to say that "BLA BLA NO WARRANTY BLA BLA NO
> > MERCHANTABILITY BLA BLA NO PARTICULAR PURPOSE."

>
> Now, you have brought in the term `undefined behavior'. *Is that what we
> have here? *The relevant sections as they have been traced back from
> 14.6/7 do not actually use the term.


For me the difference between "ill-formed, no diagnostic is required"
and "undefined behavior" is next to none.

"no diagnostic is required" is slightly worse news since it clearly
states that there is a defect made by developer (no doubt there) that
developer must diagnose himself on platforms that do not diagnose it
and such platforms are legal.

"undefined behavior" means that something may happen but standard
refuses to say what it is. Results of some "undefined behavior"s are
predictable with most implementations. Implementations however may
freely change the results (or make them less predictable) with other
compilation options (or with next version or with service patch to
current version) and keep being standard conformant.

Both are about equally bad news to developer who has to maintain code
that contains such things.

> If so, the conclusion would then appears to be that, in compiling the
> OP's original code, VC++ was invoking undefined behaviour and/or, at the
> very least, exhibiting Standards non-compliance; that, although I was
> wrong in my original analysis to suggest that "this `error' should, in
> fact, be diagnosed on other grounds," it is, nonetheless, an error on
> the part of VC++.


VC++ did not diagnose something that it is not required to diagnose.
No error done by VC++. Possibly it is even described what it does on
some page of MSDN. OP is required to diagnose it by other means and
not rely on VC, since it is ill formed code.

> If this is how it is, does this generalize out? *Do *all* uses of the
> phrase "no diagnostic required" instantly impart Standard non-compliance
> to the code in question, and perhaps also undefined behavior?


Yes, all uses of it are about violations of something that shall be
otherwise in C++ code to make that code correct.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ISE Testbench/Schematic Generation ignores package Dipl.-Ing. Hanns-Walter Schulz VHDL 5 04-26-2005 02:45 PM
VC6 Compiler ignores Array indexing? Ultraman Aries MCSD 2 06-05-2004 01:46 PM
Mozilla Firefox ignores GetRight. Watchman Firefox 1 04-08-2004 07:59 AM
Errors, errors, errors Mark Goldin ASP .Net 2 01-17-2004 08:05 PM
formsauthentication ignores web.config Dirk Meusel ASP .Net 4 08-29-2003 06:17 PM



Advertisments