Alex Rivera | Logout

What C program behaves differently in run-time when compiled with C89 and C99?

Asked 2011-11-17T05:58:30.413
15

I found the following snippet (I think in Wikipedia) that creates a different run-time when C++ comments are recognized than when not:

int a = 4 //* This is a comment, but where does it end? */ 2
  ;

But until now that's been the only one (variants excluded).

I'm not interested in differentiating using __STDC__ and the like, and not in programs that C89 will not compile.

Are there other programs/snippets producing a different run-time with C89 than C99?

Edit
Report

1 Answer

6

This program will print 0.000000 on a conforming C89 implementation and 1.000000 on a conforming C99 implementation:

#include <stdio.h>
#include <stdlib.h>

int main()
{
    double d = strtod("0x1", NULL);
    printf("%f\n", d);
    return 0;
}
answered 2011-11-17T10:26:18.050

Your Answer