Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #85698
| From | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: Differences between C and C++ |
| Date | 2022-07-27 11:11 -0700 |
| Organization | None to speak of |
| Message-ID | <878roexw6c.fsf@nosuchdomain.example.com> (permalink) |
| References | (8 earlier) <tbp194$eje$1@gioia.aioe.org> <87wnbzya2e.fsf@nosuchdomain.example.com> <tbqqr2$g7e$1@gioia.aioe.org> <3526ff38-3c29-45ab-a390-7bc6e6354164n@googlegroups.com> <tbrjd2$1fks$1@gioia.aioe.org> |
Muttley@dastardlyhq.com writes:
> On Wed, 27 Jul 2022 01:56:23 -0700 (PDT)
> =?UTF-8?B?w5bDtiBUaWli?= <ootiib@hot.ee> wrote:
>>On Wednesday, 27 July 2022 at 10:52:22 UTC+3, Mut...@dastardlyhq.com wrote:
>>> >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.
>>> I'm aware of all this. My point is why are some C semantics considered
>>> compilable (albeit with warnings) but the original example of &(struct s){1}
>>
>>> isn't and causes an error even though its perfectly legal in C.
>>
>>It is because while the compilers implemented extension of supporting
>>compound literals almost like in C, the result in those extensions is
>>temporary whose lifetime will last only to end of full-expression. Taking
>
> The expressions lifetime - and hence the temporary shouldn't end until the
> function being called returns. It should remain on the stack of the calling
> function which is probably what happens in C.
>
>>Why they did not implement the semantics fully like in C is because they
>>used it like kind of alternative syntax sugar to list-initialization. Since
>>C++14 however they can not heap-allocate initializer-lists (and did not
>>do it even before C++14). So the compound literal extension is temporary
>>for ease of implementation. Some of compilers that do it are open source
>>so if you want you can perhaps implement more close to C extension
>>to those.
>
> Why? Since they're also already C compilers the code to do it already exists
> inside them and is probably a case of setting an internal flag to call it.
Because they're not also already C compilers. A C and C++ compiler
might share the same backend and a lot of other infrastructure, but the
front ends are going to be separate.
--
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 */
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Differences between C and C++ Juha Nieminen <nospam@thanks.invalid> - 2022-07-25 13:14 +0000
Re: Differences between C and C++ "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2022-07-25 16:18 +0200
Re: Differences between C and C++ Paavo Helde <eesnimi@osa.pri.ee> - 2022-07-25 18:47 +0300
Re: Differences between C and C++ Paavo Helde <eesnimi@osa.pri.ee> - 2022-07-25 19:49 +0300
Re: Differences between C and C++ Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-07-25 19:38 +0100
Re: Differences between C and C++ Öö Tiib <ootiib@hot.ee> - 2022-07-25 08:51 -0700
Re: Differences between C and C++ Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-07-25 17:14 +0100
Re: Differences between C and C++ Muttley@dastardlyhq.com - 2022-07-25 16:19 +0000
Re: Differences between C and C++ Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-07-25 19:28 +0100
Re: Differences between C and C++ Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-07-25 12:21 -0700
Re: Differences between C and C++ Muttley@dastardlyhq.com - 2022-07-26 07:54 +0000
Re: Differences between C and C++ Juha Nieminen <nospam@thanks.invalid> - 2022-07-26 08:00 +0000
Re: Differences between C and C++ Muttley@dastardlyhq.com - 2022-07-26 08:09 +0000
Re: Differences between C and C++ Öö Tiib <ootiib@hot.ee> - 2022-07-26 02:42 -0700
Re: Differences between C and C++ Muttley@dastardlyhq.com - 2022-07-26 15:29 +0000
Re: Differences between C and C++ scott@slp53.sl.home (Scott Lurndal) - 2022-07-26 16:30 +0000
Re: Differences between C and C++ Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-07-26 11:59 -0700
Re: Differences between C and C++ Muttley@dastardlyhq.com - 2022-07-27 07:52 +0000
Re: Differences between C and C++ Öö Tiib <ootiib@hot.ee> - 2022-07-27 01:56 -0700
Re: Differences between C and C++ Muttley@dastardlyhq.com - 2022-07-27 14:51 +0000
Re: Differences between C and C++ Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-07-27 11:11 -0700
Re: Differences between C and C++ Juha Nieminen <nospam@thanks.invalid> - 2022-07-26 06:09 +0000
Re: Differences between C and C++ Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-07-27 17:33 +0100
Re: Differences between C and C++ Chris Vine <chris@cvine--nospam--.freeserve.co.uk> - 2022-07-25 17:45 +0100
Re: Differences between C and C++ Paul N <gw7rib@aol.com> - 2022-07-27 10:09 -0700
Re: Differences between C and C++ Bo Persson <bo@bo-persson.se> - 2022-07-27 19:28 +0200
Re: Differences between C and C++ Paul N <gw7rib@aol.com> - 2022-07-27 11:43 -0700
Re: Differences between C and C++ David Brown <david.brown@hesbynett.no> - 2022-07-29 18:04 +0200
Re: Differences between C and C++ Richard Damon <Richard@Damon-Family.org> - 2022-07-29 18:47 -0400
Re: Differences between C and C++ David Brown <david.brown@hesbynett.no> - 2022-07-30 14:08 +0200
Re: Differences between C and C++ Muttley@dastardlyhq.com - 2022-07-28 08:03 +0000
Re: Differences between C and C++ Öö Tiib <ootiib@hot.ee> - 2022-07-28 01:57 -0700
Re: Differences between C and C++ Muttley@dastardlyhq.com - 2022-07-28 09:04 +0000
Re: Differences between C and C++ Juha Nieminen <nospam@thanks.invalid> - 2022-07-28 06:53 +0000
Re: Differences between C and C++ Richard Damon <Richard@Damon-Family.org> - 2022-07-28 07:33 -0400
Re: Differences between C and C++ Bo Persson <bo@bo-persson.se> - 2022-07-28 15:04 +0200
Re: Differences between C and C++ Muttley@dastardlyhq.com - 2022-07-28 15:11 +0000
Re: Differences between C and C++ Paavo Helde <eesnimi@osa.pri.ee> - 2022-07-28 20:03 +0300
Re: Differences between C and C++ Juha Nieminen <nospam@thanks.invalid> - 2022-07-29 07:56 +0000
Re: Differences between C and C++ Paavo Helde <eesnimi@osa.pri.ee> - 2022-07-29 12:03 +0300
Re: Differences between C and C++ Muttley@dastardlyhq.com - 2022-07-29 09:28 +0000
Re: Differences between C and C++ Juha Nieminen <nospam@thanks.invalid> - 2022-07-29 12:27 +0000
Re: Differences between C and C++ Öö Tiib <ootiib@hot.ee> - 2022-07-29 05:43 -0700
Re: Differences between C and C++ Muttley@dastardlyhq.com - 2022-07-29 14:14 +0000
Re: Differences between C and C++ Öö Tiib <ootiib@hot.ee> - 2022-07-29 08:25 -0700
Re: Differences between C and C++ Muttley@dastardlyhq.com - 2022-07-29 15:48 +0000
Re: Differences between C and C++ Öö Tiib <ootiib@hot.ee> - 2022-07-29 13:12 -0700
Re: Differences between C and C++ Muttley@dastardlyhq.com - 2022-07-30 09:28 +0000
Re: Differences between C and C++ Öö Tiib <ootiib@hot.ee> - 2022-07-30 03:39 -0700
Re: Differences between C and C++ Muttley@dastardlyhq.com - 2022-07-30 14:23 +0000
Re: Differences between C and C++ Öö Tiib <ootiib@hot.ee> - 2022-07-30 19:07 -0700
Re: Differences between C and C++ Muttley@dastardlyhq.com - 2022-07-31 07:22 +0000
Re: Differences between C and C++ Öö Tiib <ootiib@hot.ee> - 2022-07-31 06:07 -0700
Re: Differences between C and C++ muttley@dastardlyhq.com - 2022-07-31 16:36 +0000
Re: Differences between C and C++ Öö Tiib <ootiib@hot.ee> - 2022-08-01 01:12 -0700
Re: Differences between C and C++ Juha Nieminen <nospam@thanks.invalid> - 2022-07-29 22:47 +0000
Re: Differences between C and C++ Öö Tiib <ootiib@hot.ee> - 2022-07-30 03:48 -0700
Re: Differences between C and C++ Öö Tiib <ootiib@hot.ee> - 2022-07-29 05:16 -0700
Re: Differences between C and C++ Manfred <noname@add.invalid> - 2022-07-30 02:14 +0200
Re: Differences between C and C++ Juha Nieminen <nospam@thanks.invalid> - 2022-07-31 14:39 +0000
Re: Differences between C and C++ "Fred. Zwarts" <F.Zwarts@KVI.nl> - 2022-07-31 18:49 +0200
Re: Differences between C and C++ Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2022-07-31 14:49 -0700
Re: Differences between C and C++ Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-07-31 17:03 -0700
Re: Differences between C and C++ Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2022-08-01 00:16 -0700
Re: Differences between C and C++ Ike Naar <ike@sdf.org> - 2022-08-01 07:27 +0000
Re: Differences between C and C++ Paavo Helde <eesnimi@osa.pri.ee> - 2022-08-01 10:47 +0300
Re: Differences between C and C++ Paavo Helde <eesnimi@osa.pri.ee> - 2022-08-01 10:34 +0300
Re: Differences between C and C++ Manfred <noname@add.invalid> - 2022-08-03 01:20 +0200
Re: Differences between C and C++ Juha Nieminen <nospam@thanks.invalid> - 2022-08-03 07:59 +0000
Re: Differences between C and C++ Bo Persson <bo@bo-persson.se> - 2022-08-03 12:45 +0200
Re: Differences between C and C++ Juha Nieminen <nospam@thanks.invalid> - 2022-08-03 10:53 +0000
Re: Differences between C and C++ Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2022-08-03 03:58 -0700
Re: Differences between C and C++ Paavo Helde <eesnimi@osa.pri.ee> - 2022-08-03 14:49 +0300
Re: Differences between C and C++ Öö Tiib <ootiib@hot.ee> - 2022-08-03 23:31 -0700
Re: Differences between C and C++ Juha Nieminen <nospam@thanks.invalid> - 2022-08-01 11:29 +0000
Re: Differences between C and C++ Bo Persson <bo@bo-persson.se> - 2022-08-01 14:39 +0200
Re: Differences between C and C++ Juha Nieminen <nospam@thanks.invalid> - 2022-08-02 05:43 +0000
Re: Differences between C and C++ Manfred <noname@add.invalid> - 2022-08-03 01:13 +0200
Re: Differences between C and C++ Paavo Helde <eesnimi@osa.pri.ee> - 2022-08-03 09:34 +0300
Re: Differences between C and C++ Muttley@dastardlyhq.com - 2022-07-29 09:22 +0000
Re: Differences between C and C++ Paavo Helde <eesnimi@osa.pri.ee> - 2022-07-29 13:53 +0300
Re: Differences between C and C++ Paavo Helde <eesnimi@osa.pri.ee> - 2022-07-29 14:13 +0300
Re: Differences between C and C++ Muttley@dastardlyhq.com - 2022-07-29 14:11 +0000
Re: Differences between C and C++ Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2022-07-28 06:16 -0700
csiph-web