Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #82378
| Path | csiph.com!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
| Newsgroups | comp.lang.c++, comp.lang.c |
| Subject | Re: Does this program have the specified behavior? |
| Date | Thu, 18 Nov 2021 11:15:41 +0000 |
| Organization | A noiseless patient Spider |
| Lines | 26 |
| Message-ID | <874k89ogte.fsf@bsb.me.uk> (permalink) |
| References | <TeidndjwvpeU5Qn8nZ2dnUU7-QmdnZ2d@giganews.com> <2ce7a201-45d4-49aa-a512-2ca01a4fbd36n@googlegroups.com> <L6KdnUDjcci1FAn8nZ2dnUU7-V_NnZ2d@giganews.com> <536lJ.49729$JZ3.33398@fx05.iad> <dtOdnfVlRJHziwj8nZ2dnUU7-QHNnZ2d@giganews.com> <sn4s2o$tke$1@gioia.aioe.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain |
| Injection-Info | reader02.eternal-september.org; posting-host="b6e96055cde3ec5785fc7fa92034678e"; logging-data="17440"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19boZCW4OChlEfIpxjwliQm7NgExhT9Ehk=" |
| Cancel-Lock | sha1:cqEr/4n34vJ04aPLHDrVKfYnWlM= sha1:k5lq2NNVYd6n9KlT47I4AKMtepY= |
| X-BSB-Auth | 1.a0ed9f7fda913165b909.20211118111541GMT.874k89ogte.fsf@bsb.me.uk |
| Xref | csiph.com comp.lang.c++:82378 comp.lang.c:163465 |
Cross-posted to 2 groups.
Show key headers only | View raw
Juha Nieminen <nospam@thanks.invalid> writes:
> In comp.lang.c++ olcott <NoOne@nowhere.com> wrote:
>>>> typedef int (*ptr)();
>>>>
>>>> int H(ptr x, ptr y)
>>>> {
>>>> x(y); // direct execution of P(P)
>>>> return 1;
>>>> }
>>
>> This code does compile and run correctly.
>
> It might compile as C, but it shouldn't compile as C++, because it's trying
> to call an int(*)() with a parameter, even though that function (that the
> pointer is pointing to does not take any parameter.)
Just as it must not compile in C++, this code must compile in C. The
meaning of empty ()s in a function declaration is different between the
two languages.
When I tidied up the code, I wrote C, not C++, because C has a more
suitable type available.
--
Ben.
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Do this program have the specified behavior? olcott <NoOne@NoWhere.com> - 2021-11-16 21:33 -0600
Re: Do this program have the specified behavior? wij <wyniijj@gmail.com> - 2021-11-16 20:10 -0800
Does this program have the specified behavior? olcott <NoOne@NoWhere.com> - 2021-11-16 22:46 -0600
Re: Does this program have the specified behavior? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-11-16 21:12 -0800
Re: Does this program have the specified behavior? olcott <NoOne@NoWhere.com> - 2021-11-17 08:33 -0600
Re: Does this program have the specified behavior? Richard Damon <Richard@Damon-Family.org> - 2021-11-17 06:53 -0500
Re: Does this program have the specified behavior? olcott <NoOne@NoWhere.com> - 2021-11-17 08:49 -0600
Re: Does this program have the specified behavior? Juha Nieminen <nospam@thanks.invalid> - 2021-11-18 06:32 +0000
Re: Does this program have the specified behavior? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-11-18 11:15 +0000
Re: Does this program have the specified behavior? olcott <NoOne@NoWhere.com> - 2021-11-18 08:59 -0600
Re: Does this program have the specified behavior? olcott <NoOne@NoWhere.com> - 2021-11-18 08:58 -0600
Re: Does this program have the specified behavior? Anurag Ranjan <anuragranjan630@gmail.com> - 2021-11-17 22:00 +0000
csiph-web