Non-strictly-conforming and unspecified versus undefined behavior

Non-strictly-conforming and unspecified versus undefined behavior

Post by Keith Thom » Sun, 20 Feb 2005 07:52:29


[[ comp.programming.threads dropped ]]

James Kuyper < XXXX@XXXXX.COM > writes:


I think it was politically useful in getting the standard approved.

It might be useful to have another category between "strictly
conforming" and "conforming". Programs in this category could depend
only on language and library features defined by the standard, but
would be allowed to produce output dependent on unspecified or
implementation-defined (but not undefined) behavior. For example,
this program:

#include <stdio.h>
#include <limits.h>
int main(void)
{
printf("INT_MAX = %d\n", INT_MAX);
return 0;
}

is not strictly conforming, but it would fall into this category.
Call it "portably conforming", perhaps.

--
Keith Thompson (The_Other_Keith) XXXX@XXXXX.COM < http://www.yqcomputer.com/ ~kst>
San Diego Supercomputer Center <*> < http://www.yqcomputer.com/ ~kst>
We must do something. This is something. Therefore, we must do this.
 
 
 

Non-strictly-conforming and unspecified versus undefined behavior

Post by Keith Thom » Thu, 24 Feb 2005 05:15:07

Dropping comp.programming.threads ...

"Douglas A. Gwyn" < XXXX@XXXXX.COM > writes:


A conforming implementation is required to "accept" any strictly
conforming program.

C99 4p3 says:

A program that is correct in all other aspects, operating on
correct data, containing unspecified behavior shall be a correct
program and act in accordance with 5.1.2.3.

An example of such a program is:

#include <stdio.h>
#include <limits.h>
int main(void)
{
printf("INT_MAX = %d\n", INT_MAX);
return 0;
}

Is a conforming implementation required to "accept" the above program?
If so, the category of s.c. program is not "precisely what any
conforming C implementation must accept". If not, what does C99 4p3
mean (how can the program "act in accordance with 5.1.2.3" if it's not
"accepted")?

--
Keith Thompson (The_Other_Keith) XXXX@XXXXX.COM < http://www.yqcomputer.com/ ~kst>
San Diego Supercomputer Center <*> < http://www.yqcomputer.com/ ~kst>
We must do something. This is something. Therefore, we must do this.