Path: csiph.com!news.mixmin.net!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c++ Subject: Re: Differences between C and C++ Date: Tue, 26 Jul 2022 11:59:21 -0700 Organization: None to speak of Lines: 52 Message-ID: <87wnbzya2e.fsf@nosuchdomain.example.com> References: <87k081tbjm.fsf@bsb.me.uk> <87r129yp5a.fsf@nosuchdomain.example.com> MIME-Version: 1.0 Content-Type: text/plain Injection-Info: reader01.eternal-september.org; posting-host="4ccf06c8faeecc2e9e6925153f25a68d"; logging-data="2249126"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+nlstWU7/+c5yGr92jlnn7" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Cancel-Lock: sha1:kQfK/sxBwTzYifKBVXXUVymqBng= sha1:QtL1JvMOvtF5p8+Hubu7mC3bB0s= Xref: csiph.com comp.lang.c++:85667 Muttley@dastardlyhq.com writes: > On Tue, 26 Jul 2022 02:42:09 -0700 (PDT) > =?UTF-8?B?w5bDtiBUaWli?= wrote: >>On Tuesday, 26 July 2022 at 11:09:14 UTC+3, Mut...@dastardlyhq.com wrote: >>> On Tue, 26 Jul 2022 08:00:25 -0000 (UTC) >>> Juha Nieminen wrote: >>> >Mut...@dastardlyhq.com wrote: >>> >>>C++ doesn't have compound literals, but it has some other features (that >>> >>>C doesn't) that make `f((struct s){1})` valid, but in C++ it's not an >>> >>>lvalue, so `&(struct s){1}` is not valid. >>> >> >>> >> Certainly doesn't work with Clang though you'd think if the same compiler >> >>> >> can do it in C mode it should do it in C++ mode if there are no side >>effects >>> >> of doing so. >>> > >>> >If the C++ standard doesn't consider it valid, then the compiler shouldn't >>> >consider it valid (C++) either, even if it just so happens to be valid C. >>> Is that specifically states its not valid or simply doesn't mention it. >>> >>> Most C++ compilers will compile some C constructs which are not technically >>> legal in C++ such as non consts pointing to string literals, variable length >> >>> arrays and variadic macros. >> >>It is then clearly said in documentation of such compilers. Also most >>compilers provide standard compliant mode (like -pedantic of gcc) that >>issues warnings about extensions used in code (and standard mandates >>nothing else). > > And? Juha said: > > "If the C++ standard doesn't consider it valid, then the compiler shouldn't > consider it valid (C++) either" > > Clearly plenty of compilers do consider non standard C++ valid. Plenty of C++ compilers accept non standard C++ *in certain modes*. The C++ standard requires certain errors to be diagnosed. A C++ compiler that fails to diagnose, for example, an attempt to use a VLA is not a conforming compiler. Most C++ compilers are non-conforming by default, quietly accepting extensions that are incompatible with the standard. All conforming C++ compilers provide a way to issue all required diagnostics. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com Working, but not speaking, for Philips void Void(void) { Void(); } /* The recursive call of the void */