Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

BASIC is the Computer Science equivalent of `Scientific Creationism'.


devel / comp.lang.c++ / What does this code print ?

SubjectAuthor
* What does this code print ?Bonita Montero
`* Re: What does this code print ?Ben Bacarisse
 +* Re: What does this code print ?Kenny McCormack
 |`* Re: What does this code print ?Bonita Montero
 | +* Re: What does this code print ?Scott Lurndal
 | |+- Re: What does this code print ?Bo Persson
 | |`* Re: What does this code print ?Bonita Montero
 | | `* Re: What does this code print ?Ben Bacarisse
 | |  `- Re: What does this code print ?Bonita Montero
 | `* Re: What does this code print ?Richard Damon
 |  +- Re: What does this code print ?Scott Lurndal
 |  `* Re: What does this code print ?Bonita Montero
 |   `* Re: What does this code print ?Richard Damon
 |    `* Re: What does this code print ?Bonita Montero
 |     +- Re: What does this code print ?Chris M. Thomasson
 |     `* Re: What does this code print ?Richard Damon
 |      `- Re: What does this code print ?Chris M. Thomasson
 +- Re: What does this code print ?Bonita Montero
 +* Re: What does this code print ?Chris M. Thomasson
 |+- Re: What does this code print ?Chris M. Thomasson
 |`- Re: What does this code print ?Bonita Montero
 `* Re: What does this code print ?Chris M. Thomasson
  `* Re: What does this code print ?Bonita Montero
   +* Re: What does this code print ?Richard Damon
   |`* Re: What does this code print ?Bonita Montero
   | `* Re: What does this code print ?Richard Damon
   |  `* Re: What does this code print ?Bonita Montero
   |   `* Re: What does this code print ?Richard Damon
   |    `* Re: What does this code print ?Bonita Montero
   |     `- Re: What does this code print ?Chris M. Thomasson
   +* Re: What does this code print ?Kaz Kylheku
   |+* Re: What does this code print ?Chris M. Thomasson
   ||`* Re: What does this code print ?Kaz Kylheku
   || +- Re: What does this code print ?Chris M. Thomasson
   || `* Re: What does this code print ?Paavo Helde
   ||  `* Re: What does this code print ?Chris M. Thomasson
   ||   `* Re: What does this code print ?Kaz Kylheku
   ||    `* Re: What does this code print ?Paavo Helde
   ||     `* Re: What does this code print ?Kaz Kylheku
   ||      `* Re: What does this code print ?Chris M. Thomasson
   ||       `- Re: What does this code print ?Chris M. Thomasson
   |`* Re: What does this code print ?Bonita Montero
   | `* Re: What does this code print ?Kaz Kylheku
   |  +- Re: What does this code print ?Richard Damon
   |  `- Re: What does this code print ?Bonita Montero
   +* Re: What does this code print ?Richard Damon
   |`* Re: What does this code print ?Bonita Montero
   | +* Re: What does this code print ?Bonita Montero
   | |+* Re: What does this code print ?Bonita Montero
   | ||`* Re: What does this code print ?Richard Damon
   | || `* Re: What does this code print ?Bonita Montero
   | ||  `* Re: What does this code print ?Richard Damon
   | ||   +* Re: What does this code print ?Bonita Montero
   | ||   |`- Re: What does this code print ?Richard Damon
   | ||   `* Re: What does this code print ?Bonita Montero
   | ||    `* Re: What does this code print ?Kaz Kylheku
   | ||     `* Re: What does this code print ?Bonita Montero
   | ||      `* Re: What does this code print ?Kaz Kylheku
   | ||       +- Re: What does this code print ?Richard Damon
   | ||       `* Re: What does this code print ?Chris M. Thomasson
   | ||        `* Re: What does this code print ?Kaz Kylheku
   | ||         `* Re: What does this code print ?Bonita Montero
   | ||          +* Re: What does this code print ?Richard Damon
   | ||          |`* Re: What does this code print ?Bonita Montero
   | ||          | `* Re: What does this code print ?Richard Damon
   | ||          |  `* Re: What does this code print ?Bonita Montero
   | ||          |   `* Re: What does this code print ?Richard Damon
   | ||          |    `* Re: What does this code print ?Bonita Montero
   | ||          |     `* Re: What does this code print ?Richard Damon
   | ||          |      `* Re: What does this code print ?Bonita Montero
   | ||          |       `* Re: What does this code print ?Richard Damon
   | ||          |        `* Re: What does this code print ?Bonita Montero
   | ||          |         `* Re: What does this code print ?Richard Damon
   | ||          |          `* Re: What does this code print ?Bonita Montero
   | ||          |           +- Re: What does this code print ?Branimir Maksimovic
   | ||          |           `* Re: What does this code print ?Richard Damon
   | ||          |            `* Re: What does this code print ?Bonita Montero
   | ||          |             `* Re: What does this code print ?Richard Damon
   | ||          |              `* Re: What does this code print ?Bonita Montero
   | ||          |               +* Re: What does this code print ?Richard Damon
   | ||          |               |+* Re: What does this code print ?Bonita Montero
   | ||          |               ||+* Re: What does this code print ?Richard Damon
   | ||          |               |||`* Re: What does this code print ?Bonita Montero
   | ||          |               ||| `* Re: What does this code print ?Richard Damon
   | ||          |               |||  `* Re: What does this code print ?Bonita Montero
   | ||          |               |||   `* Re: What does this code print ?Richard Damon
   | ||          |               |||    `* Re: What does this code print ?Bonita Montero
   | ||          |               |||     `* Re: What does this code print ?Kaz Kylheku
   | ||          |               |||      `* Re: What does this code print ?Bonita Montero
   | ||          |               |||       `* Re: What does this code print ?Richard Damon
   | ||          |               |||        `- Re: What does this code print ?Bonita Montero
   | ||          |               ||`* Re: What does this code print ?Branimir Maksimovic
   | ||          |               || `- Re: What does this code print ?Bonita Montero
   | ||          |               |`* Re: What does this code print ?Scott Lurndal
   | ||          |               | `- Re: What does this code print ?Richard Damon
   | ||          |               `* Re: What does this code print ?Kaz Kylheku
   | ||          |                `- Re: What does this code print ?Bonita Montero
   | ||          `* Re: What does this code print ?Kaz Kylheku
   | ||           +* Re: What does this code print ?Bo Persson
   | ||           |`- Re: What does this code print ?Kaz Kylheku
   | ||           `* Re: What does this code print ?Bonita Montero
   | |`* Re: What does this code print ?Richard Damon
   | +* Re: What does this code print ?Scott Lurndal
   | `- Re: What does this code print ?Richard Damon
   `* Re: What does this code print ?Chris M. Thomasson

Pages:123456
What does this code print ?

<ug54sf$1ki2m$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2131&group=comp.lang.c%2B%2B#2131

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: What does this code print ?
Date: Wed, 11 Oct 2023 05:30:25 +0200
Organization: A noiseless patient Spider
Lines: 18
Message-ID: <ug54sf$1ki2m$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 11 Oct 2023 03:30:23 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="58ae219398109e77e36db779894cfd28";
logging-data="1722454"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Ef2ZK/qO3LMr4SgTbwI829/euuiab0zg="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:MFnMNms6WcfWZ88IO09LQs+Rrpw=
Content-Language: de-DE
 by: Bonita Montero - Wed, 11 Oct 2023 03:30 UTC

#include <iostream>

using namespace std;

int main()
{ auto lambda = []( int a ) -> int
{
thread_local int i = 0;
return i++ + a;
};
int (__fastcall *volatile pFnFastcall)( int ) = lambda;
int (__stdcall *volatile pFnStdcall)( int ) = lambda;
cout << pFnFastcall( 10 ) << endl;
cout << pFnStdcall( 9 ) << endl;
}

Don't compile it yourself, just guess.

Re: What does this code print ?

<87lec95n0t.fsf@bsb.me.uk>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2133&group=comp.lang.c%2B%2B#2133

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.usenet@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c++
Subject: Re: What does this code print ?
Date: Wed, 11 Oct 2023 14:03:46 +0100
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <87lec95n0t.fsf@bsb.me.uk>
References: <ug54sf$1ki2m$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="2e91839ee387702d4c2caeb7b10fd37b";
logging-data="1941170"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX180ExUIqR/DgDKk+SrDskzjebuZAFA1iUM="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:dkJoxhzt0uorjwZp80PwjLa7k44=
sha1:Jd5tGoMcUWzxPXSf17xZ5EvXpZs=
X-BSB-Auth: 1.1025027eec8abc62f11f.20231011140346BST.87lec95n0t.fsf@bsb.me.uk
 by: Ben Bacarisse - Wed, 11 Oct 2023 13:03 UTC

Bonita Montero <Bonita.Montero@gmail.com> writes:

> #include <iostream>
>
> using namespace std;
>
> int main()
> {
> auto lambda = []( int a ) -> int
> {
> thread_local int i = 0;
> return i++ + a;
> };
> int (__fastcall *volatile pFnFastcall)( int ) = lambda;
> int (__stdcall *volatile pFnStdcall)( int ) = lambda;
> cout << pFnFastcall( 10 ) << endl;
> cout << pFnStdcall( 9 ) << endl;
> }
>
> Don't compile it yourself,

An easy injunction to follow since it has syntax errors! Presumably
those undeclared identifiers (or proprietary keywords?) have some
meaning to your compiler.

> just guess.

--
Ben.

Re: What does this code print ?

<ug66v8$21ehl$1@news.xmission.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2134&group=comp.lang.c%2B%2B#2134

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.lang.c++
Subject: Re: What does this code print ?
Date: Wed, 11 Oct 2023 13:12:08 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <ug66v8$21ehl$1@news.xmission.com>
References: <ug54sf$1ki2m$1@dont-email.me> <87lec95n0t.fsf@bsb.me.uk>
Injection-Date: Wed, 11 Oct 2023 13:12:08 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="2144821"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Wed, 11 Oct 2023 13:12 UTC

In article <87lec95n0t.fsf@bsb.me.uk>,
Ben Bacarisse <ben.usenet@bsb.me.uk> wrote:
>Bonita Montero <Bonita.Montero@gmail.com> writes:
>
>> #include <iostream>
>>
>> using namespace std;
>>
>> int main()
>> {
>> auto lambda = []( int a ) -> int
>> {
>> thread_local int i = 0;
>> return i++ + a;
>> };
>> int (__fastcall *volatile pFnFastcall)( int ) = lambda;
>> int (__stdcall *volatile pFnStdcall)( int ) = lambda;
>> cout << pFnFastcall( 10 ) << endl;
>> cout << pFnStdcall( 9 ) << endl;
>> }
>>
>> Don't compile it yourself,
>
>An easy injunction to follow since it has syntax errors! Presumably
>those undeclared identifiers (or proprietary keywords?) have some
>meaning to your compiler.

Actually, it is pretty easy to answer OP's question. Here's what it
prints:

<stdin>: In function 'int main()':
<stdin>:12:8: error: '__fastcall' was not declared in this scope
<stdin>:12:3: error: expected primary-expression before 'int'
<stdin>:13:8: error: '__stdcall' was not declared in this scope
<stdin>:13:3: error: expected primary-expression before 'int'
<stdin>:14:11: error: 'pFnFastcall' was not declared in this scope
<stdin>:15:11: error: 'pFnStdcall' was not declared in this scope

And it is, in theory at least, possible to predict that without using a
compiler (though, truth to be told, I did cheat and use the compiler).

--
The randomly chosen signature file that would have appeared here is more than 4
lines long. As such, it violates one or more Usenet RFCs. In order to remain
in compliance with said RFCs, the actual sig can be found at the following URL:
http://user.xmission.com/~gazelle/Sigs/InsaneParty

Re: What does this code print ?

<ug6li5$1ur0k$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2137&group=comp.lang.c%2B%2B#2137

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!nntp.comgw.net!weretis.net!feeder8.news.weretis.net!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: What does this code print ?
Date: Wed, 11 Oct 2023 19:21:12 +0200
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <ug6li5$1ur0k$1@dont-email.me>
References: <ug54sf$1ki2m$1@dont-email.me> <87lec95n0t.fsf@bsb.me.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 11 Oct 2023 17:21:09 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="58ae219398109e77e36db779894cfd28";
logging-data="2059284"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19G+4Wz6Z6ar1LFVMcyIQDlu3QDVTJmbX4="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:qsJ4sGTMgso0BRjZWaXUbFeKYRc=
In-Reply-To: <87lec95n0t.fsf@bsb.me.uk>
Content-Language: de-DE
 by: Bonita Montero - Wed, 11 Oct 2023 17:21 UTC

Am 11.10.2023 um 15:03 schrieb Ben Bacarisse:
> Bonita Montero <Bonita.Montero@gmail.com> writes:
>
>> #include <iostream>
>>
>> using namespace std;
>>
>> int main()
>> {
>> auto lambda = []( int a ) -> int
>> {
>> thread_local int i = 0;
>> return i++ + a;
>> };
>> int (__fastcall *volatile pFnFastcall)( int ) = lambda;
>> int (__stdcall *volatile pFnStdcall)( int ) = lambda;
>> cout << pFnFastcall( 10 ) << endl;
>> cout << pFnStdcall( 9 ) << endl;
>> }
>>
>> Don't compile it yourself,
>
> An easy injunction to follow since it has syntax errors! ...

The code compiles with MSVC.

Re: What does this code print ?

<ug6lk8$1ur0k$2@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2138&group=comp.lang.c%2B%2B#2138

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: What does this code print ?
Date: Wed, 11 Oct 2023 19:22:19 +0200
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <ug6lk8$1ur0k$2@dont-email.me>
References: <ug54sf$1ki2m$1@dont-email.me> <87lec95n0t.fsf@bsb.me.uk>
<ug66v8$21ehl$1@news.xmission.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 11 Oct 2023 17:22:16 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="58ae219398109e77e36db779894cfd28";
logging-data="2059284"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18quhe2B1hBxHIR4xZ2cgdhSQ5Fy//iHH4="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:s28JAZ+vX/QFpTT3b/Lx2kKQ7qw=
In-Reply-To: <ug66v8$21ehl$1@news.xmission.com>
Content-Language: de-DE
 by: Bonita Montero - Wed, 11 Oct 2023 17:22 UTC

Am 11.10.2023 um 15:12 schrieb Kenny McCormack:

> Actually, it is pretty easy to answer OP's question. Here's what it
> prints:
>
> <stdin>: In function 'int main()':
> <stdin>:12:8: error: '__fastcall' was not declared in this scope
> <stdin>:12:3: error: expected primary-expression before 'int'
> <stdin>:13:8: error: '__stdcall' was not declared in this scope
> <stdin>:13:3: error: expected primary-expression before 'int'
> <stdin>:14:11: error: 'pFnFastcall' was not declared in this scope
> <stdin>:15:11: error: 'pFnStdcall' was not declared in this scope
>
> And it is, in theory at least, possible to predict that without using a
> compiler (though, truth to be told, I did cheat and use the compiler).

Use a compiler which knows __fastcall and __stdcall.

Re: What does this code print ?

<P6BVM.37407$rbid.23540@fx18.iad>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2139&group=comp.lang.c%2B%2B#2139

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!rocksolid2!news.neodome.net!npeer.as286.net!npeer-ng0.as286.net!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx18.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: scott@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: What does this code print ?
Newsgroups: comp.lang.c++
References: <ug54sf$1ki2m$1@dont-email.me> <87lec95n0t.fsf@bsb.me.uk> <ug66v8$21ehl$1@news.xmission.com> <ug6lk8$1ur0k$2@dont-email.me>
Lines: 23
Message-ID: <P6BVM.37407$rbid.23540@fx18.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Wed, 11 Oct 2023 17:41:03 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Wed, 11 Oct 2023 17:41:03 GMT
X-Received-Bytes: 1644
 by: Scott Lurndal - Wed, 11 Oct 2023 17:41 UTC

Bonita Montero <Bonita.Montero@gmail.com> writes:
>Am 11.10.2023 um 15:12 schrieb Kenny McCormack:
>
>> Actually, it is pretty easy to answer OP's question. Here's what it
>> prints:
>>
>> <stdin>: In function 'int main()':
>> <stdin>:12:8: error: '__fastcall' was not declared in this scope
>> <stdin>:12:3: error: expected primary-expression before 'int'
>> <stdin>:13:8: error: '__stdcall' was not declared in this scope
>> <stdin>:13:3: error: expected primary-expression before 'int'
>> <stdin>:14:11: error: 'pFnFastcall' was not declared in this scope
>> <stdin>:15:11: error: 'pFnStdcall' was not declared in this scope
>>
>> And it is, in theory at least, possible to predict that without using a
>> compiler (though, truth to be told, I did cheat and use the compiler).
>
>Use a compiler which knows __fastcall and __stdcall.
>

Why?

gcc and clang are far superior.

Re: What does this code print ?

<koo7ikFbrgsU1@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2140&group=comp.lang.c%2B%2B#2140

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: bo@bo-persson.se (Bo Persson)
Newsgroups: comp.lang.c++
Subject: Re: What does this code print ?
Date: Wed, 11 Oct 2023 20:24:20 +0200
Lines: 29
Message-ID: <koo7ikFbrgsU1@mid.individual.net>
References: <ug54sf$1ki2m$1@dont-email.me> <87lec95n0t.fsf@bsb.me.uk>
<ug66v8$21ehl$1@news.xmission.com> <ug6lk8$1ur0k$2@dont-email.me>
<P6BVM.37407$rbid.23540@fx18.iad>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net lUIrVxvesVpeJTXMCHtJvg10/cWAWpq17ZLrbEe0jYy0V3gg7G
Cancel-Lock: sha1:wOQMl1oYdxhuvlgYcQQmJE7+4hA= sha256:mGXelpZhkHMkgnXPu7Z7+2kJCNUwc4IuUiJKyaRCik4=
User-Agent: Mozilla Thunderbird
Content-Language: sv
In-Reply-To: <P6BVM.37407$rbid.23540@fx18.iad>
 by: Bo Persson - Wed, 11 Oct 2023 18:24 UTC

On 2023-10-11 at 19:41, Scott Lurndal wrote:
> Bonita Montero <Bonita.Montero@gmail.com> writes:
>> Am 11.10.2023 um 15:12 schrieb Kenny McCormack:
>>
>>> Actually, it is pretty easy to answer OP's question. Here's what it
>>> prints:
>>>
>>> <stdin>: In function 'int main()':
>>> <stdin>:12:8: error: '__fastcall' was not declared in this scope
>>> <stdin>:12:3: error: expected primary-expression before 'int'
>>> <stdin>:13:8: error: '__stdcall' was not declared in this scope
>>> <stdin>:13:3: error: expected primary-expression before 'int'
>>> <stdin>:14:11: error: 'pFnFastcall' was not declared in this scope
>>> <stdin>:15:11: error: 'pFnStdcall' was not declared in this scope
>>>
>>> And it is, in theory at least, possible to predict that without using a
>>> compiler (though, truth to be told, I did cheat and use the compiler).
>>
>> Use a compiler which knows __fastcall and __stdcall.
>>
>
> Why?
>
> gcc and clang are far superior.

The irony is that the compiler that "knows them", also knows to ignore
them. That's why the lambda is compatible with both.

They used to have a meaning for 32-bit Windows.

Re: What does this code print ?

<ug6tpq$20e0f$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2141&group=comp.lang.c%2B%2B#2141

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: What does this code print ?
Date: Wed, 11 Oct 2023 12:41:46 -0700
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <ug6tpq$20e0f$1@dont-email.me>
References: <ug54sf$1ki2m$1@dont-email.me> <87lec95n0t.fsf@bsb.me.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 11 Oct 2023 19:41:46 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c5bb16ad9304e9e0eb20a0d2592634e9";
logging-data="2111503"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/weVgpqcMebgBKITK8A483tC90nP9K6Mo="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:gaZanxqFee5ExBMJxFxdtDmGflc=
Content-Language: en-US
In-Reply-To: <87lec95n0t.fsf@bsb.me.uk>
 by: Chris M. Thomasson - Wed, 11 Oct 2023 19:41 UTC

On 10/11/2023 6:03 AM, Ben Bacarisse wrote:
> Bonita Montero <Bonita.Montero@gmail.com> writes:
>
>> #include <iostream>
>>
>> using namespace std;
>>
>> int main()
>> {
>> auto lambda = []( int a ) -> int
>> {
>> thread_local int i = 0;
>> return i++ + a;
>> };
>> int (__fastcall *volatile pFnFastcall)( int ) = lambda;
>> int (__stdcall *volatile pFnStdcall)( int ) = lambda;
>> cout << pFnFastcall( 10 ) << endl;
>> cout << pFnStdcall( 9 ) << endl;
>> }
>>
>> Don't compile it yourself,
>
> An easy injunction to follow since it has syntax errors! Presumably
> those undeclared identifiers (or proprietary keywords?) have some
> meaning to your compiler.
>
>> just guess.
>

Afaict, around 99.(9)% sure, Bonita is a troll.

Re: What does this code print ?

<ug6tts$20e0f$2@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2142&group=comp.lang.c%2B%2B#2142

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: What does this code print ?
Date: Wed, 11 Oct 2023 12:43:56 -0700
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <ug6tts$20e0f$2@dont-email.me>
References: <ug54sf$1ki2m$1@dont-email.me> <87lec95n0t.fsf@bsb.me.uk>
<ug6tpq$20e0f$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 11 Oct 2023 19:43:56 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c5bb16ad9304e9e0eb20a0d2592634e9";
logging-data="2111503"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18BK0Y93mzEoKN44FqouMfckk5ABFpGWO4="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:mCD9VnmAJTl5bGw4dfEXIgeSxGQ=
In-Reply-To: <ug6tpq$20e0f$1@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Wed, 11 Oct 2023 19:43 UTC

On 10/11/2023 12:41 PM, Chris M. Thomasson wrote:
> On 10/11/2023 6:03 AM, Ben Bacarisse wrote:
>> Bonita Montero <Bonita.Montero@gmail.com> writes:
>>
>>> #include <iostream>
>>>
>>> using namespace std;
>>>
>>> int main()
>>> {
>>>     auto lambda = []( int a ) -> int
>>>     {
>>>         thread_local int i = 0;
>>>         return i++ + a;
>>>     };
>>>     int (__fastcall *volatile pFnFastcall)( int ) = lambda;
>>>     int (__stdcall *volatile pFnStdcall)( int ) = lambda;
>>>     cout << pFnFastcall( 10 ) << endl;
>>>     cout << pFnStdcall( 9 ) << endl;
>>> }
>>>
>>> Don't compile it yourself,
>>
>> An easy injunction to follow since it has syntax errors!  Presumably
>> those undeclared identifiers (or proprietary keywords?) have some
>> meaning to your compiler.
>>
>>> just guess.
>>
>
> Afaict, around 99.(9)% sure, Bonita is a troll.

100% indeed

Re: What does this code print ?

<ugad9a$2va82$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2149&group=comp.lang.c%2B%2B#2149

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: What does this code print ?
Date: Fri, 13 Oct 2023 05:24:29 +0200
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <ugad9a$2va82$1@dont-email.me>
References: <ug54sf$1ki2m$1@dont-email.me> <87lec95n0t.fsf@bsb.me.uk>
<ug66v8$21ehl$1@news.xmission.com> <ug6lk8$1ur0k$2@dont-email.me>
<P6BVM.37407$rbid.23540@fx18.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 13 Oct 2023 03:24:26 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="b5f363213d1a82ccb53cf4200b86f193";
logging-data="3123458"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/GwLUpUE6qUlla1V6mdimTcerLYm0XPQg="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:bhki0NUMR2Av+5GOBVcBdLK67Qk=
In-Reply-To: <P6BVM.37407$rbid.23540@fx18.iad>
Content-Language: de-DE
 by: Bonita Montero - Fri, 13 Oct 2023 03:24 UTC

Am 11.10.2023 um 19:41 schrieb Scott Lurndal:

> Bonita Montero <Bonita.Montero@gmail.com> writes:

>> Use a compiler which knows __fastcall and __stdcall.

> Why?
> gcc and clang are far superior.

In this case it's about functionality, not performance.
And clang-cl supports __fastcall and __stdcall also.

Re: What does this code print ?

<ugadbi$2va82$2@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2150&group=comp.lang.c%2B%2B#2150

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: What does this code print ?
Date: Fri, 13 Oct 2023 05:25:41 +0200
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <ugadbi$2va82$2@dont-email.me>
References: <ug54sf$1ki2m$1@dont-email.me> <87lec95n0t.fsf@bsb.me.uk>
<ug6tpq$20e0f$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 13 Oct 2023 03:25:38 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="b5f363213d1a82ccb53cf4200b86f193";
logging-data="3123458"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18NuaHX0K7fzni1sTgS8gMfCIRpgTA2H0M="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:UaAXG+QBfs+6WexqR7Ty1IChjVs=
In-Reply-To: <ug6tpq$20e0f$1@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Fri, 13 Oct 2023 03:25 UTC

Am 11.10.2023 um 21:41 schrieb Chris M. Thomasson:

>> Bonita Montero <Bonita.Montero@gmail.com> writes:

>>> #include <iostream>
>>>
>>> using namespace std;
>>>
>>> int main()
>>> {
>>>     auto lambda = []( int a ) -> int
>>>     {
>>>         thread_local int i = 0;
>>>         return i++ + a;
>>>     };
>>>     int (__fastcall *volatile pFnFastcall)( int ) = lambda;
>>>     int (__stdcall *volatile pFnStdcall)( int ) = lambda;
>>>     cout << pFnFastcall( 10 ) << endl;
>>>     cout << pFnStdcall( 9 ) << endl;
>>> }
>>>

> Afaict, around 99.(9)% sure, Bonita is a troll.

Yes, because I didn't use a race detector on the above code.

Re: What does this code print ?

<ugaeqo$2vefi$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2151&group=comp.lang.c%2B%2B#2151

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: What does this code print ?
Date: Thu, 12 Oct 2023 20:50:49 -0700
Organization: A noiseless patient Spider
Lines: 31
Message-ID: <ugaeqo$2vefi$1@dont-email.me>
References: <ug54sf$1ki2m$1@dont-email.me> <87lec95n0t.fsf@bsb.me.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 13 Oct 2023 03:50:48 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="2f6cae8585e78fbcab118262ba2efe09";
logging-data="3127794"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+mQTymQUuyuhni2Pl44FHbvyHzC4zRLh0="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:FuN4QhXQCiB1FupkaMwEXQ+nBVw=
In-Reply-To: <87lec95n0t.fsf@bsb.me.uk>
Content-Language: en-US
 by: Chris M. Thomasson - Fri, 13 Oct 2023 03:50 UTC

On 10/11/2023 6:03 AM, Ben Bacarisse wrote:
> Bonita Montero <Bonita.Montero@gmail.com> writes:
>
>> #include <iostream>
>>
>> using namespace std;
>>
>> int main()
>> {
>> auto lambda = []( int a ) -> int
>> {
>> thread_local int i = 0;
>> return i++ + a;
>> };
>> int (__fastcall *volatile pFnFastcall)( int ) = lambda;
>> int (__stdcall *volatile pFnStdcall)( int ) = lambda;
>> cout << pFnFastcall( 10 ) << endl;
>> cout << pFnStdcall( 9 ) << endl;
>> }
>>
>> Don't compile it yourself,
>
> An easy injunction to follow since it has syntax errors! Presumably
> those undeclared identifiers (or proprietary keywords?) have some
> meaning to your compiler.
>
>> just guess.
>

What is 10 * 10? It's one hundred percent that the lovely Bonita is a troll.

Re: What does this code print ?

<ugapal$31eim$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2152&group=comp.lang.c%2B%2B#2152

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: What does this code print ?
Date: Fri, 13 Oct 2023 08:50:01 +0200
Organization: A noiseless patient Spider
Lines: 43
Message-ID: <ugapal$31eim$1@dont-email.me>
References: <ug54sf$1ki2m$1@dont-email.me> <87lec95n0t.fsf@bsb.me.uk>
<ugaeqo$2vefi$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 13 Oct 2023 06:49:57 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="b5f363213d1a82ccb53cf4200b86f193";
logging-data="3193430"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+FaCz8h5qA1slJ8Q/ADjh9xq6z/52fcoY="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:H/c/c717zoEhLlJY8StmrOcsTa8=
In-Reply-To: <ugaeqo$2vefi$1@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Fri, 13 Oct 2023 06:50 UTC

Am 13.10.2023 um 05:50 schrieb Chris M. Thomasson:
> On 10/11/2023 6:03 AM, Ben Bacarisse wrote:
>> Bonita Montero <Bonita.Montero@gmail.com> writes:
>>
>>> #include <iostream>
>>>
>>> using namespace std;
>>>
>>> int main()
>>> {
>>>     auto lambda = []( int a ) -> int
>>>     {
>>>         thread_local int i = 0;
>>>         return i++ + a;
>>>     };
>>>     int (__fastcall *volatile pFnFastcall)( int ) = lambda;
>>>     int (__stdcall *volatile pFnStdcall)( int ) = lambda;
>>>     cout << pFnFastcall( 10 ) << endl;
>>>     cout << pFnStdcall( 9 ) << endl;
>>> }
>>>
>>> Don't compile it yourself,
>>
>> An easy injunction to follow since it has syntax errors!  Presumably
>> those undeclared identifiers (or proprietary keywords?) have some
>> meaning to your compiler.
>>
>>> just guess.
>>
>
>
> What is 10 * 10?
> It's one hundred percent that the lovely Bonita is a troll.

O.k., I'll explain it: the lambda is compiled twice for each cal-
ling convention but in contrast to a generic lambda the thread
local variable "i" exists only once for both "instantiations" !
With a generic lambda there would be an "i" for each instanti-
ation of the lambda's calling operator. I thought the people
here should be able to think about that without compiling the
code.
And you call that trolling ...

Re: What does this code print ?

<ugbq8q$19fre$2@i2pn2.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2154&group=comp.lang.c%2B%2B#2154

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!.POSTED!not-for-mail
From: richard@damon-family.org (Richard Damon)
Newsgroups: comp.lang.c++
Subject: Re: What does this code print ?
Date: Fri, 13 Oct 2023 12:12:10 -0400
Organization: i2pn2 (i2pn.org)
Message-ID: <ugbq8q$19fre$2@i2pn2.org>
References: <ug54sf$1ki2m$1@dont-email.me> <87lec95n0t.fsf@bsb.me.uk>
<ug66v8$21ehl$1@news.xmission.com> <ug6lk8$1ur0k$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 13 Oct 2023 16:12:10 -0000 (UTC)
Injection-Info: i2pn2.org;
logging-data="1359726"; mail-complaints-to="usenet@i2pn2.org";
posting-account="diqKR1lalukngNWEqoq9/uFtbkm5U+w3w6FQ0yesrXg";
User-Agent: Mozilla Thunderbird
In-Reply-To: <ug6lk8$1ur0k$2@dont-email.me>
Content-Language: en-US
 by: Richard Damon - Fri, 13 Oct 2023 16:12 UTC

On 10/11/23 1:22 PM, Bonita Montero wrote:
> Am 11.10.2023 um 15:12 schrieb Kenny McCormack:
>
>> Actually, it is pretty easy to answer OP's question.  Here's what it
>> prints:
>>
>> <stdin>: In function 'int main()':
>> <stdin>:12:8: error: '__fastcall' was not declared in this scope
>> <stdin>:12:3: error: expected primary-expression before 'int'
>> <stdin>:13:8: error: '__stdcall' was not declared in this scope
>> <stdin>:13:3: error: expected primary-expression before 'int'
>> <stdin>:14:11: error: 'pFnFastcall' was not declared in this scope
>> <stdin>:15:11: error: 'pFnStdcall' was not declared in this scope
>>
>> And it is, in theory at least, possible to predict that without using a
>> compiler (though, truth to be told, I did cheat and use the compiler).
>
> Use a compiler which knows __fastcall and __stdcall.
>
>

But ANY program using those, that is to be interpreted as "Standard
C++", has, by the Standard "Undefined Behavior".

So, the answer, when posted as a general "C++" question, is, it does
what ever the implementation wants it to do.

To get your answer, you need to limit the "Language" of the program to
the particular implementation you desire.

I could CORRECTLY state (if I want to go to the effort) that when I
complied the program, its output was "Bonita is a idiot", because that
is what the Damon C++ compiler generated, and it is fully conforming.

(And that answer IS a correct statement).

Re: What does this code print ?

<ugbqf7$19fre$3@i2pn2.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2155&group=comp.lang.c%2B%2B#2155

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!.POSTED!not-for-mail
From: richard@damon-family.org (Richard Damon)
Newsgroups: comp.lang.c++
Subject: Re: What does this code print ?
Date: Fri, 13 Oct 2023 12:15:35 -0400
Organization: i2pn2 (i2pn.org)
Message-ID: <ugbqf7$19fre$3@i2pn2.org>
References: <ug54sf$1ki2m$1@dont-email.me> <87lec95n0t.fsf@bsb.me.uk>
<ugaeqo$2vefi$1@dont-email.me> <ugapal$31eim$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 13 Oct 2023 16:15:35 -0000 (UTC)
Injection-Info: i2pn2.org;
logging-data="1359726"; mail-complaints-to="usenet@i2pn2.org";
posting-account="diqKR1lalukngNWEqoq9/uFtbkm5U+w3w6FQ0yesrXg";
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <ugapal$31eim$1@dont-email.me>
 by: Richard Damon - Fri, 13 Oct 2023 16:15 UTC

On 10/13/23 2:50 AM, Bonita Montero wrote:
> Am 13.10.2023 um 05:50 schrieb Chris M. Thomasson:
>> On 10/11/2023 6:03 AM, Ben Bacarisse wrote:
>>> Bonita Montero <Bonita.Montero@gmail.com> writes:
>>>
>>>> #include <iostream>
>>>>
>>>> using namespace std;
>>>>
>>>> int main()
>>>> {
>>>>     auto lambda = []( int a ) -> int
>>>>     {
>>>>         thread_local int i = 0;
>>>>         return i++ + a;
>>>>     };
>>>>     int (__fastcall *volatile pFnFastcall)( int ) = lambda;
>>>>     int (__stdcall *volatile pFnStdcall)( int ) = lambda;
>>>>     cout << pFnFastcall( 10 ) << endl;
>>>>     cout << pFnStdcall( 9 ) << endl;
>>>> }
>>>>
>>>> Don't compile it yourself,
>>>
>>> An easy injunction to follow since it has syntax errors!  Presumably
>>> those undeclared identifiers (or proprietary keywords?) have some
>>> meaning to your compiler.
>>>
>>>> just guess.
>>>
>>
>>
>> What is 10 * 10?
>> It's one hundred percent that the lovely Bonita is a troll.
>
>
> O.k., I'll explain it: the lambda is compiled twice for each cal-
> ling convention but in contrast to a generic lambda the thread
> local variable "i" exists only once for both "instantiations" !
> With a generic lambda there would be an "i" for each instanti-
> ation of the lambda's calling operator. I thought the people
> here should be able to think about that without compiling the
> code.
> And you call that trolling ...

And your lack of knowledge of how the standard actually works just shows
how little you really know.

Re: What does this code print ?

<20231013081459.652@kylheku.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2156&group=comp.lang.c%2B%2B#2156

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-4973@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c++
Subject: Re: What does this code print ?
Date: Fri, 13 Oct 2023 16:34:50 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 50
Message-ID: <20231013081459.652@kylheku.com>
References: <ug54sf$1ki2m$1@dont-email.me> <87lec95n0t.fsf@bsb.me.uk>
<ugaeqo$2vefi$1@dont-email.me> <ugapal$31eim$1@dont-email.me>
Injection-Date: Fri, 13 Oct 2023 16:34:50 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="4df2c5460e28ebd15bb9f2d6f4886b60";
logging-data="3458543"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+gQm5/ajSEz1GXFQywtsCOBcWfKuaQhog="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:FpEKwrfUa8T7W/NJj4QF9lAmu1w=
 by: Kaz Kylheku - Fri, 13 Oct 2023 16:34 UTC

On 2023-10-13, Bonita Montero <Bonita.Montero@gmail.com> wrote:
> O.k., I'll explain it: the lambda is compiled twice for each cal-

I suspect the terminology you're groping for is "inlined".

> ling convention but in contrast to a generic lambda the thread

I don't believe it. It looks like the lambda uses the default calling
convention ("__cdecl"), and is just being misused through the wrong
calling convention.

It's possible that inlining will render this consideration
moot, because if the function is inlined, then no actual calls are
happening, and there are no calling conventions.
(Compiling for a target other than x86 also renders it moot, since
the calling convention extensions are ignored on x64 and arm.
Let's assume they are there for a reason, and we are targetting x86).

Inlining is an optimization.

If your code depends on optimization (or lack thereof) in order to have
the semantics you believe it to have, it's wrong.

If the function is actually called through the wrong conventions,
there will be problems. The fastcall call will put the argument value in
a register, whereas the stdcall function will try to take it from the
stack, resulting in the callee accessing some value unrelated to the
argument.

The stdcall might be able to access the argument value, but under
stdcall, the callee is assumed to remove arguments from the stack
which the cdecl callee will not do. That could leave the stack in
sufficiently bad state that main is not able to return.

Or something; why go too deeply into guessing what incorrect code
might be doing, if we're not actually fighting a fire.

That function inlining doesn't proliferate copies of static or
thread_local variables isn't surprising at all; that's needed to
preserve semantics.

It is generic lambdas that stand in contrast. They are a macro-like
mechanism which duplicates code, due to type inference or template
argument deduction. They are also newer.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca
NOTE: If you use Google Groups, I don't see you, unless you're whitelisted.

Re: What does this code print ?

<87o7h231lr.fsf@bsb.me.uk>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2157&group=comp.lang.c%2B%2B#2157

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!news.hispagatos.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.usenet@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c++
Subject: Re: What does this code print ?
Date: Fri, 13 Oct 2023 17:53:52 +0100
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <87o7h231lr.fsf@bsb.me.uk>
References: <ug54sf$1ki2m$1@dont-email.me> <87lec95n0t.fsf@bsb.me.uk>
<ug66v8$21ehl$1@news.xmission.com> <ug6lk8$1ur0k$2@dont-email.me>
<P6BVM.37407$rbid.23540@fx18.iad> <ugad9a$2va82$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="0be012e1613f7b29f75119ae7d325a09";
logging-data="3462317"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/X86Jee77zAcbqcNdQWOrjJdwmFyEBLL4="
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:Rw4iRp707i0K85N+SrNQY+3kSPo=
sha1:GaRVz4OhrDrJ3yMu/E3ntRWtLVY=
X-BSB-Auth: 1.02183faca1a49fbc21f0.20231013175352BST.87o7h231lr.fsf@bsb.me.uk
 by: Ben Bacarisse - Fri, 13 Oct 2023 16:53 UTC

Bonita Montero <Bonita.Montero@gmail.com> writes:

> Am 11.10.2023 um 19:41 schrieb Scott Lurndal:
>
>> Bonita Montero <Bonita.Montero@gmail.com> writes:
>
>>> Use a compiler which knows __fastcall and __stdcall.
>
>> Why?
>> gcc and clang are far superior.
>
> In this case it's about functionality, not performance.
> And clang-cl supports __fastcall and __stdcall also.

Here, clang reports:

xx.cc:12:7: warning: '__fastcall' calling convention is not supported for this target [-Wignored-attributes]
int (__fastcall *volatile pFnFastcall)( int ) = lambda;
^
xx.cc:13:7: warning: '__stdcall' calling convention is not supported for this target [-Wignored-attributes]
int (__stdcall *volatile pFnStdcall)( int ) = lambda;

so "supported" in the sense that it's not a syntax error.

--
Ben.

Re: What does this code print ?

<v6fWM.8285$igw9.559@fx37.iad>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2159&group=comp.lang.c%2B%2B#2159

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!news.1d4.us!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx37.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: scott@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: What does this code print ?
Newsgroups: comp.lang.c++
References: <ug54sf$1ki2m$1@dont-email.me> <87lec95n0t.fsf@bsb.me.uk> <ug66v8$21ehl$1@news.xmission.com> <ug6lk8$1ur0k$2@dont-email.me> <ugbq8q$19fre$2@i2pn2.org>
Lines: 28
Message-ID: <v6fWM.8285$igw9.559@fx37.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Fri, 13 Oct 2023 17:27:55 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Fri, 13 Oct 2023 17:27:55 GMT
X-Received-Bytes: 1893
 by: Scott Lurndal - Fri, 13 Oct 2023 17:27 UTC

Richard Damon <richard@damon-family.org> writes:
>On 10/11/23 1:22 PM, Bonita Montero wrote:
>> Am 11.10.2023 um 15:12 schrieb Kenny McCormack:
>>
>>> Actually, it is pretty easy to answer OP's question.  Here's what it
>>> prints:
>>>
>>> <stdin>: In function 'int main()':
>>> <stdin>:12:8: error: '__fastcall' was not declared in this scope
>>> <stdin>:12:3: error: expected primary-expression before 'int'
>>> <stdin>:13:8: error: '__stdcall' was not declared in this scope
>>> <stdin>:13:3: error: expected primary-expression before 'int'
>>> <stdin>:14:11: error: 'pFnFastcall' was not declared in this scope
>>> <stdin>:15:11: error: 'pFnStdcall' was not declared in this scope
>>>
>>> And it is, in theory at least, possible to predict that without using a
>>> compiler (though, truth to be told, I did cheat and use the compiler).
>>
>> Use a compiler which knows __fastcall and __stdcall.
>>
>>
>
>But ANY program using those, that is to be interpreted as "Standard
>C++", has, by the Standard "Undefined Behavior".

And moreover, they only have different behavior on x86 (32-bit).

On x86_64, ARM64, et alia __fastcall/__stdcall are ignored, even by microsoft compilers.

Re: What does this code print ?

<ugc8bo$3cv2m$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2160&group=comp.lang.c%2B%2B#2160

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: What does this code print ?
Date: Fri, 13 Oct 2023 13:12:40 -0700
Organization: A noiseless patient Spider
Lines: 73
Message-ID: <ugc8bo$3cv2m$1@dont-email.me>
References: <ug54sf$1ki2m$1@dont-email.me> <87lec95n0t.fsf@bsb.me.uk>
<ugaeqo$2vefi$1@dont-email.me> <ugapal$31eim$1@dont-email.me>
<20231013081459.652@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 13 Oct 2023 20:12:40 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="2f6cae8585e78fbcab118262ba2efe09";
logging-data="3570774"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19QmjX+bT2qohV38WIlf9wxYhSYKleNsEk="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:6eWxBuCpu7RLKa8mu6mpQ+HoErU=
Content-Language: en-US
In-Reply-To: <20231013081459.652@kylheku.com>
 by: Chris M. Thomasson - Fri, 13 Oct 2023 20:12 UTC

On 10/13/2023 9:34 AM, Kaz Kylheku wrote:
> On 2023-10-13, Bonita Montero <Bonita.Montero@gmail.com> wrote:
>> O.k., I'll explain it: the lambda is compiled twice for each cal-
>
> I suspect the terminology you're groping for is "inlined".
>
>> ling convention but in contrast to a generic lambda the thread
>
> I don't believe it. It looks like the lambda uses the default calling
> convention ("__cdecl"), and is just being misused through the wrong
> calling convention.
>
> It's possible that inlining will render this consideration
> moot, because if the function is inlined, then no actual calls are
> happening, and there are no calling conventions.
> (Compiling for a target other than x86 also renders it moot, since
> the calling convention extensions are ignored on x64 and arm.
> Let's assume they are there for a reason, and we are targetting x86).
>
> Inlining is an optimization.
>
> If your code depends on optimization (or lack thereof) in order to have
> the semantics you believe it to have, it's wrong.
>
> If the function is actually called through the wrong conventions,
> there will be problems. The fastcall call will put the argument value in
> a register, whereas the stdcall function will try to take it from the
> stack, resulting in the callee accessing some value unrelated to the
> argument.
>
> The stdcall might be able to access the argument value, but under
> stdcall, the callee is assumed to remove arguments from the stack
> which the cdecl callee will not do. That could leave the stack in
> sufficiently bad state that main is not able to return.
>
> Or something; why go too deeply into guessing what incorrect code
> might be doing, if we're not actually fighting a fire.
>
> That function inlining doesn't proliferate copies of static or
> thread_local variables isn't surprising at all; that's needed to
> preserve semantics.

Afaict, thread_local should be using the thread that is calling main in
this example.

I should create a new thread for this, but:

Fwiw, actually, I am trying to understand how dtors are called wrt TLS
when a thread is destroyed (aka, join returns) in C++. POSIX and C11
makes this rather easy wrt:

Notice the dtor that we can use wrt (thread local storage) TLS:

https://en.cppreference.com/w/c/thread/tss_create

This is basically how POSIX does it via:

pthread_key_t
_______________
pthread_key_create
pthread_setspecific
pthread_getspecific
pthread_key_delete
_______________

Easy.

>
> It is generic lambdas that stand in contrast. They are a macro-like
> mechanism which duplicates code, due to type inference or template
> argument deduction. They are also newer.
>

Re: What does this code print ?

<20231013192405.57@kylheku.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2164&group=comp.lang.c%2B%2B#2164

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-4973@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c++
Subject: Re: What does this code print ?
Date: Sat, 14 Oct 2023 02:36:46 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 73
Message-ID: <20231013192405.57@kylheku.com>
References: <ug54sf$1ki2m$1@dont-email.me> <87lec95n0t.fsf@bsb.me.uk>
<ugaeqo$2vefi$1@dont-email.me> <ugapal$31eim$1@dont-email.me>
<20231013081459.652@kylheku.com> <ugc8bo$3cv2m$1@dont-email.me>
Injection-Date: Sat, 14 Oct 2023 02:36:46 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="0b58a9e51d01575394271395df94341e";
logging-data="3839884"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX189NqqE/cKoxCpDsKYNbvv/MlryzYfEhJE="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:sI41NuwDCqp1SGAqOih/DMwhLQY=
 by: Kaz Kylheku - Sat, 14 Oct 2023 02:36 UTC

On 2023-10-13, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
> Afaict, thread_local should be using the thread that is calling main in
> this example.

If the program has not started any threads, so that there is only
the primary thread that starts at main, thread_local could be
replaced by static.

> I should create a new thread for this, but:
>
> Fwiw, actually, I am trying to understand how dtors are called wrt TLS
> when a thread is destroyed (aka, join returns) in C++. POSIX and C11
> makes this rather easy wrt:
>
> Notice the dtor that we can use wrt (thread local storage) TLS:
>
> https://en.cppreference.com/w/c/thread/tss_create
>
> This is basically how POSIX does it via:
>
> pthread_key_t
> _______________
> pthread_key_create
> pthread_setspecific
> pthread_getspecific
> pthread_key_delete
> _______________

The pthread_key_delete function is rarely needed. We would need it in,
say, a dynamically loaded component that is being unloaded.

Usually keys have an indefinite lifetime. The values don't, of course.

In pthread_key_create we can register a destructor function
that is used upon thread death.

This is extremely badly designed in POSIX, because that thread which is
terminated is tasked with the clean-up of the keys: the destructors
run in its context.

While it's performing the clean-up for one key, it might inadvertently
call some code which reinstalls the value for another key.

In recognition of this problem, the API is designed with a silly
iteration mechanism. If the terminating thread has reinstanted
values for any thread specific keys, those are iterated on again
and the destructors are called, up to some number of times.

What you want is to allow the thread to just exit. In that thread's
context, at most you want to do unwinding of its scoped resources.

The thread-specific keys values of a thread should persist until it
has terminated, and then be cleaned up at some later time by
*another* thread. Kind of like a garbage collection pass.

If the thread is pthread_join-ed, the one doing the joining would
be a good candidate. For detached threads, it could be done by some
internal thread, or foisted onto some existing application thread
when it happens to bump into the pthread key API.

That would prevent the need for iterations because, since another
thread is running the destructors, and not the original one,
That other thread can only set its own key values, and not those
of another thread, let alone a dead one.

Some 25 years ago I made a TLS API like that, with the cleanup
done on another thread. It worked well.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca
NOTE: If you use Google Groups, I don't see you, unless you're whitelisted.

Re: What does this code print ?

<ugd2r5$3ls76$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2166&group=comp.lang.c%2B%2B#2166

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: What does this code print ?
Date: Fri, 13 Oct 2023 20:44:35 -0700
Organization: A noiseless patient Spider
Lines: 49
Message-ID: <ugd2r5$3ls76$1@dont-email.me>
References: <ug54sf$1ki2m$1@dont-email.me> <87lec95n0t.fsf@bsb.me.uk>
<ugaeqo$2vefi$1@dont-email.me> <ugapal$31eim$1@dont-email.me>
<20231013081459.652@kylheku.com> <ugc8bo$3cv2m$1@dont-email.me>
<20231013192405.57@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 14 Oct 2023 03:44:37 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="2cf987f24d0b23d2f1e28b52964b1913";
logging-data="3862758"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18bAKkhJ/0L1O+bV/m+iyN+NnZqOPao0I0="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:9e1xoBkgXeB0k7znnlz1KQUqMaA=
In-Reply-To: <20231013192405.57@kylheku.com>
Content-Language: en-US
 by: Chris M. Thomasson - Sat, 14 Oct 2023 03:44 UTC

On 10/13/2023 7:36 PM, Kaz Kylheku wrote:
> On 2023-10-13, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
>> Afaict, thread_local should be using the thread that is calling main in
>> this example.
>
> If the program has not started any threads, so that there is only
> the primary thread that starts at main, thread_local could be
> replaced by static.
>
>> I should create a new thread for this, but:
>>
>> Fwiw, actually, I am trying to understand how dtors are called wrt TLS
>> when a thread is destroyed (aka, join returns) in C++. POSIX and C11
>> makes this rather easy wrt:
>>
>> Notice the dtor that we can use wrt (thread local storage) TLS:
>>
>> https://en.cppreference.com/w/c/thread/tss_create
>>
>> This is basically how POSIX does it via:
>>
>> pthread_key_t
>> _______________
>> pthread_key_create
>> pthread_setspecific
>> pthread_getspecific
>> pthread_key_delete
>> _______________
>
> The pthread_key_delete function is rarely needed. We would need it in,
> say, a dynamically loaded component that is being unloaded.
>
> Usually keys have an indefinite lifetime. The values don't, of course.
>
> In pthread_key_create we can register a destructor function
> that is used upon thread death.
>
> This is extremely badly designed in POSIX, because that thread which is
> terminated is tasked with the clean-up of the keys: the destructors
> run in its context.

Sorry for the brief response. Actually, I never had a problem with it in
my code before. However, I have had to debug some code created by
others. Should have some more time tomorrow to code some tests up. Am
curious if some of my C compilers support C11 threads yet like Pelles C:

http://www.smorgasbordet.com/pellesc/

[...]

Re: What does this code print ?

<ugdkql$3p94s$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2167&group=comp.lang.c%2B%2B#2167

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: eesnimi@osa.pri.ee (Paavo Helde)
Newsgroups: comp.lang.c++
Subject: Re: What does this code print ?
Date: Sat, 14 Oct 2023 11:51:31 +0300
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <ugdkql$3p94s$1@dont-email.me>
References: <ug54sf$1ki2m$1@dont-email.me> <87lec95n0t.fsf@bsb.me.uk>
<ugaeqo$2vefi$1@dont-email.me> <ugapal$31eim$1@dont-email.me>
<20231013081459.652@kylheku.com> <ugc8bo$3cv2m$1@dont-email.me>
<20231013192405.57@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 14 Oct 2023 08:51:33 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="83cefa56723c8357b2a9a681a7fab4ca";
logging-data="3974300"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18rTQEYKyFnt5QhGVPLeF4XixYTqiwrCA4="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:bpW9PacKvH94OZidhELLPvgoGMc=
Content-Language: en-US
In-Reply-To: <20231013192405.57@kylheku.com>
 by: Paavo Helde - Sat, 14 Oct 2023 08:51 UTC

14.10.2023 05:36 Kaz Kylheku kirjutas:
>
> The thread-specific keys values of a thread should persist until it
> has terminated, and then be cleaned up at some later time by
> *another* thread. Kind of like a garbage collection pass.

So, a destructor of an object which has specifically declared to live in
a single thread only, will be called in some other thread?

Sure, seems very intuitive, what might go wrong!

Re: What does this code print ?

<uge6bt$3spt4$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2168&group=comp.lang.c%2B%2B#2168

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: What does this code print ?
Date: Sat, 14 Oct 2023 15:50:53 +0200
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <uge6bt$3spt4$1@dont-email.me>
References: <ug54sf$1ki2m$1@dont-email.me> <87lec95n0t.fsf@bsb.me.uk>
<ug66v8$21ehl$1@news.xmission.com> <ug6lk8$1ur0k$2@dont-email.me>
<P6BVM.37407$rbid.23540@fx18.iad> <ugad9a$2va82$1@dont-email.me>
<87o7h231lr.fsf@bsb.me.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 14 Oct 2023 13:50:53 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="e339d1a9ba3717ee50ff255201bd4cec";
logging-data="4089764"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ybYwlHRWAppl4fvRMGOeUf61/cqBGX44="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:LwqsuDVQR3/b9AZRYpyhQLGt3Ow=
In-Reply-To: <87o7h231lr.fsf@bsb.me.uk>
Content-Language: de-DE
 by: Bonita Montero - Sat, 14 Oct 2023 13:50 UTC

Am 13.10.2023 um 18:53 schrieb Ben Bacarisse:
> Bonita Montero <Bonita.Montero@gmail.com> writes:
>
>> Am 11.10.2023 um 19:41 schrieb Scott Lurndal:
>>
>>> Bonita Montero <Bonita.Montero@gmail.com> writes:
>>
>>>> Use a compiler which knows __fastcall and __stdcall.
>>
>>> Why?
>>> gcc and clang are far superior.
>>
>> In this case it's about functionality, not performance.
>> And clang-cl supports __fastcall and __stdcall also.
>
> Here, clang reports:

clang-cl, not clang.

>
> xx.cc:12:7: warning: '__fastcall' calling convention is not supported for this target [-Wignored-attributes]
> int (__fastcall *volatile pFnFastcall)( int ) = lambda;
> ^
> xx.cc:13:7: warning: '__stdcall' calling convention is not supported for this target [-Wignored-attributes]
> int (__stdcall *volatile pFnStdcall)( int ) = lambda;
>
> so "supported" in the sense that it's not a syntax error.
>

Re: What does this code print ?

<uge6f5$3spt4$2@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2169&group=comp.lang.c%2B%2B#2169

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: What does this code print ?
Date: Sat, 14 Oct 2023 15:52:37 +0200
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <uge6f5$3spt4$2@dont-email.me>
References: <ug54sf$1ki2m$1@dont-email.me> <87lec95n0t.fsf@bsb.me.uk>
<ug66v8$21ehl$1@news.xmission.com> <ug6lk8$1ur0k$2@dont-email.me>
<ugbq8q$19fre$2@i2pn2.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 14 Oct 2023 13:52:37 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="e339d1a9ba3717ee50ff255201bd4cec";
logging-data="4089764"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/22n4a21+474kQhSkJDAVSpPHJybAOHcc="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:+TLMuiftyGVn1bgus3e+NdAHQRU=
In-Reply-To: <ugbq8q$19fre$2@i2pn2.org>
Content-Language: de-DE
 by: Bonita Montero - Sat, 14 Oct 2023 13:52 UTC

Am 13.10.2023 um 18:12 schrieb Richard Damon:
> On 10/11/23 1:22 PM, Bonita Montero wrote:
>> Am 11.10.2023 um 15:12 schrieb Kenny McCormack:
>>
>>> Actually, it is pretty easy to answer OP's question.  Here's what it
>>> prints:
>>>
>>> <stdin>: In function 'int main()':
>>> <stdin>:12:8: error: '__fastcall' was not declared in this scope
>>> <stdin>:12:3: error: expected primary-expression before 'int'
>>> <stdin>:13:8: error: '__stdcall' was not declared in this scope
>>> <stdin>:13:3: error: expected primary-expression before 'int'
>>> <stdin>:14:11: error: 'pFnFastcall' was not declared in this scope
>>> <stdin>:15:11: error: 'pFnStdcall' was not declared in this scope
>>>
>>> And it is, in theory at least, possible to predict that without using a
>>> compiler (though, truth to be told, I did cheat and use the compiler).
>>
>> Use a compiler which knows __fastcall and __stdcall.
>>
>>
>
> But ANY program using those, that is to be interpreted as "Standard
> C++", has, by the Standard "Undefined Behavior".

This is just a Windows program. If you don't like it, don't worry
about it.Others might be able to understand this without Windows,
but you can't.

>
> So, the answer, when posted as a general "C++" question, is, it does
> what ever the implementation wants it to do.
>
> To get your answer, you need to limit the "Language" of the program to
> the particular implementation you desire.
>
> I could CORRECTLY state (if I want to go to the effort) that when I
> complied the program, its output was "Bonita is a idiot", because that
> is what the Damon C++ compiler generated, and it is fully conforming.
>
> (And that answer IS a correct statement).

Re: What does this code print ?

<uge6gg$3spt4$3@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2170&group=comp.lang.c%2B%2B#2170

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: What does this code print ?
Date: Sat, 14 Oct 2023 15:53:20 +0200
Organization: A noiseless patient Spider
Lines: 51
Message-ID: <uge6gg$3spt4$3@dont-email.me>
References: <ug54sf$1ki2m$1@dont-email.me> <87lec95n0t.fsf@bsb.me.uk>
<ugaeqo$2vefi$1@dont-email.me> <ugapal$31eim$1@dont-email.me>
<ugbqf7$19fre$3@i2pn2.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 14 Oct 2023 13:53:20 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="e339d1a9ba3717ee50ff255201bd4cec";
logging-data="4089764"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19PiDjDj1em562rz/FwpzosCz3hjwJv69g="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:QyllBptO2bOdbUPVBPzlqfBpv4s=
Content-Language: de-DE
In-Reply-To: <ugbqf7$19fre$3@i2pn2.org>
 by: Bonita Montero - Sat, 14 Oct 2023 13:53 UTC

Am 13.10.2023 um 18:15 schrieb Richard Damon:
> On 10/13/23 2:50 AM, Bonita Montero wrote:
>> Am 13.10.2023 um 05:50 schrieb Chris M. Thomasson:
>>> On 10/11/2023 6:03 AM, Ben Bacarisse wrote:
>>>> Bonita Montero <Bonita.Montero@gmail.com> writes:
>>>>
>>>>> #include <iostream>
>>>>>
>>>>> using namespace std;
>>>>>
>>>>> int main()
>>>>> {
>>>>>     auto lambda = []( int a ) -> int
>>>>>     {
>>>>>         thread_local int i = 0;
>>>>>         return i++ + a;
>>>>>     };
>>>>>     int (__fastcall *volatile pFnFastcall)( int ) = lambda;
>>>>>     int (__stdcall *volatile pFnStdcall)( int ) = lambda;
>>>>>     cout << pFnFastcall( 10 ) << endl;
>>>>>     cout << pFnStdcall( 9 ) << endl;
>>>>> }
>>>>>
>>>>> Don't compile it yourself,
>>>>
>>>> An easy injunction to follow since it has syntax errors!  Presumably
>>>> those undeclared identifiers (or proprietary keywords?) have some
>>>> meaning to your compiler.
>>>>
>>>>> just guess.
>>>>
>>>
>>>
>>> What is 10 * 10?
>>> It's one hundred percent that the lovely Bonita is a troll.
>>
>>
>> O.k., I'll explain it: the lambda is compiled twice for each cal-
>> ling convention but in contrast to a generic lambda the thread
>> local variable "i" exists only once for both "instantiations" !
>> With a generic lambda there would be an "i" for each instanti-
>> ation of the lambda's calling operator. I thought the people
>> here should be able to think about that without compiling the
>> code.
>> And you call that trolling ...
>
> And your lack of knowledge of how the standard actually works just shows
> how little you really know.

I know that this isn't standard C++.
But this doesn't matter for my question.

Pages:123456
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor