From: Noone Really <nooneatnowhere@earthlink.net>
Newsgroups: comp.lang.c
Subject: Re: FAQ 20.27: Is C++ a superset of C? Can I use a C++ compiler to compile C code?
Date: Sun, 31 Jan 1999 17:47:25 -0700
Message-ID: <36B4F99D.97D84E5D@earthlink.net>

Larry Weiss wrote:
> FAQ 20.27 promises that there are "some legal C constructs which
> are not legal C++". I would like to see some examples of this.

By C, the FAQ meant, and I guess we still mean, the current language, not proposals for C9x.

There are a number of these. I once worked out a pretty big list, but do not remember it now. However, you just asked for examples:

1) auto conversion from void * to any object/incomplete type:

    void *one; char *two =one;

2) new keywords (a number of these)

    int new;

3) due to structs becoming scoped

      struct x {
        struct y { int z; } w;
      };
      struct y v;

4) due to struct tags becoming typedefs:

    struct y {int z;};
    int f(int(y)); f(3);

5) due to prototypes being required

     int f(); f(3);

6) implicit int rules

     main(){}

7) Recursive call to main

8) Due to // comments

   int x = 2//*why???*/2;
   int y;

> FAQ 20.27 also promised that "the two also define the meaning
> of some common constructs differently". I would like to see
> some examples of that.

A few examples which come to mind immediately:

1) Due to // comments:

   int x = 2//*why???*/2
   ;

2) due to character literals being type char and not int etc.
So, if sizeof(int) != 1,

   sizeof('a')
differs in the two languages

3) Due to struct scopes

   struct y {int z;};
   {
    struct x {
        struct y { char z; } w;
    };
    struct y v;
    return sizeof v.z;
   }

In addition, there are many cases where C compilers need to issue a diagnostic, but which do not require diagnostic because they are valid C++ code. That is kind of obvious, and hence I do not provide examples.