constraint violations and compilation

R

Richard Weeks

My question, stated as simply as possible, is: must a constraint
violation, as defined by the standard, cause compilation to halt?

I believe that in the presence of a constraint violation, at
least one diagnostic is required, which, at the discretion of the
compiler writer, may be either an "error" or a "warning."
Generally however, an error halts compilation and a warning does
not. This would seem to imply that it is up to the compiler
writer to decide which constraint violations halt compilation and
which do not.

Richard
 
?

=?iso-2022-kr?q?Harald_van_D=0E=29=26=0Fk?=

My question, stated as simply as possible, is: must a constraint
violation, as defined by the standard, cause compilation to halt?
No.

I believe that in the presence of a constraint violation, at least one
diagnostic is required, which, at the discretion of the compiler writer,
may be either an "error" or a "warning."

It may be any diagnostic. Several compilers have diagnostic categories
other than "error" and "warning", for example "fatal error",
"notification", or "remark".
Generally however, an error
halts compilation and a warning does not. This would seem to imply that
it is up to the compiler writer to decide which constraint violations
halt compilation and which do not.

This is correct.
 
R

Richard Heathfield

Richard Weeks said:
My question, stated as simply as possible, is: must a constraint
violation, as defined by the standard, cause compilation to halt?

No. It does mean that a diagnostic message must be produced, but the
Standard does not require translation to be halted.
I believe that in the presence of a constraint violation, at
least one diagnostic is required, which, at the discretion of the
compiler writer, may be either an "error" or a "warning."

Generally however, an error halts compilation and a warning does
not. This would seem to imply that it is up to the compiler
writer to decide which constraint violations halt compilation and
which do not.

It is entirely up to the implementation, yes - all it *has* to do is
diagnose at least one of any syntax errors and constraint violations it
encounters. The implementation is then free to choose whether to continue
or to halt translation.
 
J

Jack Klein

My question, stated as simply as possible, is: must a constraint
violation, as defined by the standard, cause compilation to halt?

Prior to C99, there was absolutely never any requirement on any
implementation to halt translation, nor any prohibition against
producing some sort of executable output, under any circumstances.

C99 add this:

"The implementation shall not successfully translate a preprocessing
translation unit containing a #error preprocessing directive unless it
is part of a group skipped by conditional inclusion."

Nothing to do wit constraint violations.
I believe that in the presence of a constraint violation, at
least one diagnostic is required, which, at the discretion of the
compiler writer, may be either an "error" or a "warning."
Generally however, an error halts compilation and a warning does
not. This would seem to imply that it is up to the compiler
writer to decide which constraint violations halt compilation and
which do not.

Since the actual form or wording of diagnostics is completely
unspecified, poorly worded and actually incorrect text has been output
from some compilers for decades, ex:

int main(void)
{
int arr [10];
arr = 12;
return 0;
}

Outputteth compiler: "lvalue required". Of course, arr is an lvalue.
--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html
 
K

Keith Thompson

Richard Weeks said:
My question, stated as simply as possible, is: must a constraint
violation, as defined by the standard, cause compilation to halt?
[...]

No, and if a compiler generates an executable (after producing the
required diagnostic), the behavior is undefined.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top