Saturday, February 29, 2020

Digest for comp.lang.c++@googlegroups.com - 13 updates in 1 topic

"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Feb 28 03:34PM -0800

On 2/28/2020 8:50 AM, Mr Flibble wrote:
> storing user's passwords whether they are encrypted or not on your
> servers: you should be HASHING the user password on the user's machine
> and sending that over an encrypted link.
 
Indeed. Even a nice DH exchange might be in order...
 
https://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange
 
 
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Feb 28 03:37PM -0800

>> their password in the clear?
 
> I plan to use Wireguard for encryption so it
> could be done after we have that set up.
 
How are you storing those user passwords on your end? I hope your not
storing them in the clear... You can store the HMAC'ed result, keyed
with a salt or some random element. Then instead of comparing passwords
in the clear, you can compare hash digests.
woodbrian77@gmail.com: Feb 28 04:24PM -0800

On Friday, February 28, 2020 at 5:37:35 PM UTC-6, Chris M. Thomasson wrote:
> storing them in the clear... You can store the HMAC'ed result, keyed
> with a salt or some random element. Then instead of comparing passwords
> in the clear, you can compare hash digests.
 
OK. I'm also thinking about this:
https://www.reddit.com/r/WireGuard/comments/ewzxk4/no_password_protection_at_all/
 
Perhaps I don't need passwords beyond what Wireguard provides.
 
 
Brian
Ebenezer Enterprises - In G-d we trust.
http://webEbenezer.net
Melzzzzz <Melzzzzz@zzzzz.com>: Feb 29 03:48AM

>> >> their password in the clear?
 
>> > I plan to use Wireguard for encryption so it
>> > could be done after we have that set up.
 
sending passwords over mail is highly unsecure. No one does it any more.
 
> OK. I'm also thinking about this:
> https://www.reddit.com/r/WireGuard/comments/ewzxk4/no_password_protection_at_all/
 
> Perhaps I don't need passwords beyond what Wireguard provides.
Hm, no password is something like sending public keys?
 
--
press any key to continue or any other to quit...
U ničemu ja ne uživam kao u svom statusu INVALIDA -- Zli Zec
Svi smo svedoci - oko 3 godine intenzivne propagande je dovoljno da jedan narod poludi -- Zli Zec
Na divljem zapadu i nije bilo tako puno nasilja, upravo zato jer su svi
bili naoruzani. -- Mladen Gogala
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Feb 28 09:33PM -0800

On 2/28/2020 7:48 PM, Melzzzzz wrote:
>> https://www.reddit.com/r/WireGuard/comments/ewzxk4/no_password_protection_at_all/
 
>> Perhaps I don't need passwords beyond what Wireguard provides.
> Hm, no password is something like sending public keys?
 
Very Simple scheme...
 
Password Setup:
 
Use DH to setup temporary secure channel between server and a client.
 
The client encrypts the password using this session and sends the
ciphertext to the server.
 
The server decrypts and hashes the password with a random salt.
 
The secure channel is destroyed.
 
The server stores the digest and the salt.
 
 
Password Validation:
 
Use DH to setup temporary secure channel between server and a client.
 
The client encrypts the password using this session and sends the
ciphertext to the server.
 
The server decrypts, looks up your account, hashes the password with the
stored random salt.
 
The secure channel is destroyed.
 
The server compares the stored digest vs the computed digest.
 
 
This way, the users passwords do not have to be stored.
 
This is just a simple way to do it.
 
 
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Feb 29 06:28AM

On 29/02/2020 05:33, Chris M. Thomasson wrote:
 
> Use DH to setup temporary secure channel between server and a client.
 
> The client encrypts the password using this session and sends the ciphertext to the server.
 
> The server decrypts, looks up your account, hashes the password with the stored random salt.
 
NO! Do not send the password to the fucking server, hash on the fucking CLIENT and send the fucking HASH to the fucking server.
 
/Flibble
 
--
"Snakes didn't evolve, instead talking snakes with legs changed into snakes." - Rick C. Hodgin
 
"You won't burn in hell. But be nice anyway." – Ricky Gervais
 
"I see Atheists are fighting and killing each other again, over who doesn't believe in any God the most. Oh, no..wait.. that never happens." – Ricky Gervais
 
"Suppose it's all true, and you walk up to the pearly gates, and are confronted by God," Byrne asked on his show The Meaning of Life. "What will Stephen Fry say to him, her, or it?"
"I'd say, bone cancer in children? What's that about?" Fry replied.
"How dare you? How dare you create a world to which there is such misery that is not our fault. It's not right, it's utterly, utterly evil."
"Why should I respect a capricious, mean-minded, stupid God who creates a world that is so full of injustice and pain. That's what I would say."
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Feb 28 10:34PM -0800

On 2/28/2020 10:28 PM, Mr Flibble wrote:
>> the stored random salt.
 
> NO! Do not send the password to the fucking server, hash on the fucking
> CLIENT and send the fucking HASH to the fucking server.'
 
Okay. I was thinking of sending an encrypted password using a DH secure
channel. We can most certainly hash on the client, then send the digest
to the server using a secure DH?
 
Melzzzzz <Melzzzzz@zzzzz.com>: Feb 29 06:50AM


>> The client encrypts the password using this session and sends the ciphertext to the server.
 
>> The server decrypts, looks up your account, hashes the password with the stored random salt.
 
> NO! Do not send the password to the fucking server, hash on the fucking CLIENT and send the fucking HASH to the fucking server.
 
Hash or ciphertext? Hash is same as sending it in plain text.
 
 
--
press any key to continue or any other to quit...
U ničemu ja ne uživam kao u svom statusu INVALIDA -- Zli Zec
Svi smo svedoci - oko 3 godine intenzivne propagande je dovoljno da jedan narod poludi -- Zli Zec
Na divljem zapadu i nije bilo tako puno nasilja, upravo zato jer su svi
bili naoruzani. -- Mladen Gogala
Melzzzzz <Melzzzzz@zzzzz.com>: Feb 29 06:51AM


> Okay. I was thinking of sending an encrypted password using a DH secure
> channel. We can most certainly hash on the client, then send the digest
> to the server using a secure DH?
 
When using encrypted protocol it is same. When attacker has hash it is
same as plain text.
 
--
press any key to continue or any other to quit...
U ničemu ja ne uživam kao u svom statusu INVALIDA -- Zli Zec
Svi smo svedoci - oko 3 godine intenzivne propagande je dovoljno da jedan narod poludi -- Zli Zec
Na divljem zapadu i nije bilo tako puno nasilja, upravo zato jer su svi
bili naoruzani. -- Mladen Gogala
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Feb 28 11:32PM -0800

On 2/28/2020 10:50 PM, Melzzzzz wrote:
 
>>> The server decrypts, looks up your account, hashes the password with the stored random salt.
 
>> NO! Do not send the password to the fucking server, hash on the fucking CLIENT and send the fucking HASH to the fucking server.
 
> Hash or ciphertext? Hash is same as sending it in plain text.
 
We want a ciphertext to be sent across the wire. We can use async crypto
to get a shared key, then encrypt using a symmetric cipher.
 
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Feb 29 07:34AM

On 29/02/2020 06:51, Melzzzzz wrote:
>> to the server using a secure DH?
 
> When using encrypted protocol it is same. When attacker has hash it is
> same as plain text.
 
You are missing the point: people use the same password for different things: if the hash is compromised it only compromises access to this particular server; also
you cannot gaurantee that lemons working on the server code don't log it by mistake. NEVER send password in the clear from the CLIENT computer even over encrpypted links.
Clue: you can hash a hash.
 
/Flibble
 
--
"Snakes didn't evolve, instead talking snakes with legs changed into snakes." - Rick C. Hodgin
 
"You won't burn in hell. But be nice anyway." – Ricky Gervais
 
"I see Atheists are fighting and killing each other again, over who doesn't believe in any God the most. Oh, no..wait.. that never happens." – Ricky Gervais
 
"Suppose it's all true, and you walk up to the pearly gates, and are confronted by God," Byrne asked on his show The Meaning of Life. "What will Stephen Fry say to him, her, or it?"
"I'd say, bone cancer in children? What's that about?" Fry replied.
"How dare you? How dare you create a world to which there is such misery that is not our fault. It's not right, it's utterly, utterly evil."
"Why should I respect a capricious, mean-minded, stupid God who creates a world that is so full of injustice and pain. That's what I would say."
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Feb 28 11:38PM -0800

On 2/28/2020 10:51 PM, Melzzzzz wrote:
>> to the server using a secure DH?
 
> When using encrypted protocol it is same. When attacker has hash it is
> same as plain text.
 
Exactly. This is why its good to try to setup a temporary secure
channel, just to send ciphertext to the server.
 
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Feb 28 11:40PM -0800

On 2/28/2020 11:34 PM, Mr Flibble wrote:
> you cannot gaurantee that lemons working on the server code don't log it
> by mistake. NEVER send password in the clear from the CLIENT computer
> even over encrpypted links.
 
It must use encrpypted links regardless.
 
 
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

Friday, February 28, 2020

Digest for comp.lang.c++@googlegroups.com - 4 updates in 2 topics

woodbrian77@gmail.com: Feb 27 08:19PM -0800

On Sunday, February 9, 2020 at 2:54:28 PM UTC-6, Chris M. Thomasson wrote:
> > reduced by switching from TCP to SCTP. Thanks in advance.
 
> Iirc, you require a user to "register" by sending you an email with
> their password in the clear?
 
I plan to use Wireguard for encryption so it
could be done after we have that set up.
 
 
Brian
Ebenezer Enterprises
https://github.com/Ebenezer-group/onwards
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Feb 28 04:50PM

>> their password in the clear?
 
> I plan to use Wireguard for encryption so it
> could be done after we have that set up.
 
You don't understand how passwords work do you? You should NEVER be storing user's passwords whether they are encrypted or not on your servers: you should be HASHING the user password on the user's machine and sending that over an encrypted link.
 
/Flibble
 
--
"Snakes didn't evolve, instead talking snakes with legs changed into snakes." - Rick C. Hodgin
 
"You won't burn in hell. But be nice anyway." – Ricky Gervais
 
"I see Atheists are fighting and killing each other again, over who doesn't believe in any God the most. Oh, no..wait.. that never happens." – Ricky Gervais
 
"Suppose it's all true, and you walk up to the pearly gates, and are confronted by God," Byrne asked on his show The Meaning of Life. "What will Stephen Fry say to him, her, or it?"
"I'd say, bone cancer in children? What's that about?" Fry replied.
"How dare you? How dare you create a world to which there is such misery that is not our fault. It's not right, it's utterly, utterly evil."
"Why should I respect a capricious, mean-minded, stupid God who creates a world that is so full of injustice and pain. That's what I would say."
Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo>: Feb 28 12:42AM -0500

Chris Vine wrote:
 
> You keep going on about reinterpret_cast. To remind you, the code in
> question which you previously said had undefined behaviour, and you now
> seem to say has implementation defined behaviour,
Please do not put your words in my mouth. I am saying that it is ok for C++
Standard Library "to use the compiler implementation-specific behavior"
(removing possessive case but all same words).
 
From the below definition of undefined behavior:
 
3.28 [defns.undefined]
undefined behavior
behavior for which this document imposes no requirements
[Note 1 to entry: Undefined behavior may be expected when this document omits
any explicit definition of
behavior or when a program uses an erroneous construct or erroneous data.
Permissible undefined behavior
ranges from ignoring the situation completely with unpredictable results, *to
behaving during translation or
program execution in a documented manner characteristic of the environment*
(with or without the issuance
of a diagnostic message), to terminating a translation or execution (with the
issuance of a diagnostic message).
Many erroneous program constructs do not engender undefined behavior; they are
required to be diagnosed.
Evaluation of a constant expression never exhibits behavior explicitly specified
as undefined in Clause 4
through Clause 15 of this document (7.7). — end note]
 
the compiler implementation-specific behavior means exactly that compiler
behaves "during translation or program execution in a documented manner
characteristic of the environment". As long as no requirements on this behavior
is imposed by the Standard ("this document"), it is also undefined behavior
simply by definition.
 
 
> Y* q = new(&s) Y{2};
> const int h = std::launder(reinterpret_cast<Y*>(&s))->z;
 
> So just what behaviour do you think is implementation-defined here?
Where did I say that "here" had implementation-defined behavior (for the record,
I think it may or may not have that, depending on a specific implementation)? I
did say that [the reinterpret_cast expression above] had undefined behavior
because I cannot see where the Standard imposes any requirements on that
expression (in plain English, it never tells me what the result of this
expression shall be). Hence I have no other choice than to conclude it has
undefined behavior by definition (and believe me I am not enjoying it a little
bit: I have tons of code using reinterpret_cast in similar manner -- although
some of it is protected by compiler-specific #ifdefs but mainly for different
reasons).
 
> (the mapping of pointer to integer, and the effect of conversions
> between object pointer and function pointer) but these are not relevant
> here.
That was exactly my point: even if reinterpret_cast of some mappings is defined
by a _particular_ compiler and therefore the C++ Standard Library could use it
in its implementation of std::allocator -- which gcc-9.2 Library does not do --
the reinterpret_cast behavior for the above code snippet would still be
undefined -- again, regardless of whether some particular implementation
documents it.
 
 
> Just repeating yourself does not make what you say true.
Exactly. In particular, repeating that I am wrong does not make me wrong.
 
> Let's have a
> proper explanation, preferably with reference to some authoritative
> work[1].
If the text of the latest Draft n4849 is not authoritative enough I am sorry, I
do not have the official text of C++17. Although, reinterpret_cast above would
be UB even according to C++11 -- whose official text I do have if that satisfies
you. Or do you believe there is a higher authority on the Standard then the
Standard itself?
 
> global placement new operator return by reference to the address of its
> void* argument). Unfortunately you are on the wrong side of that one
> also.
Not again, please. I thought you wanted to give a "proper explanation,
preferably with reference to some authoritative work"? Also, my being wrong
would not be unfortunate? I don't mind standing corrected, it just has not
happened so far in this particular discussion.
 
-Pavel
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Feb 28 02:44PM

On Fri, 28 Feb 2020 00:42:15 -0500
> Chris Vine wrote:
[snip]
> bit: I have tons of code using reinterpret_cast in similar manner -- although
> some of it is protected by compiler-specific #ifdefs but mainly for different
> reasons).
 
This helpfully identifies the source of your thinking. I am somewhat
reluctant to continue this because I think from our previous exchanges
it is likely to be fruitless, but here are the main provisions of the
C++17 standard which define the behaviour of this code. I would have
hoped that it would have been apparent from my earlier posts, but here
it is in extenso:
 
§4.5/3 (a complete object may be constructed in storage comprising
an array of unsigned char or of std::byte)
 
§6.8/10 (an object may be accessed through a glvalue of, and
therefore aliased by a pointer to, its dynamic type or amongst other
things a char, unsigned char or std::byte type)
 
§8.2.9/1 (static_cast<T>(v) converts the expression v to type T,
where it is one of the cases covered by §8.2.9)
 
§8.2.9/13 (the expression static_cast<T*>(static_cast<void*>(p1))
returns the pointer value unchanged (except as to type) where, as
in our case, the type of p1 and T* are not pointer-interconvertible,
provided that the alignment requirement of type T is met).
 
§8.2.10/7 (an object pointer can be converted by reinterpret_cast to
an object pointer of a different type: reinterpret_cast<cv T*>(v) is
equivalent to static_cast<cv T*>(static_cast<cv void*>(v)))
 
§8.3.6/1 ((alignof T) yields the alignment requirement of type T)
 
§10.6.2/3 (alignas(T) is the same as (alignas (alignof T)), and
results in its operand meeting the alignment requirement of T)
 
§21.6.2.3/1 (the return value of the placement new operator for single
objects is its placement pointer value unchanged, and that operator
performs no other action than return it)
 
§21.6.4 (std::launder permits access to an object that is within its
lifetime and whose storage is located at the address given by its
operand - say, in an array of unsigned char or std::byte, as the
corollary of §4.5/3).
 
You will I suspect be inclined to dismiss all this. If so, can I
invite you to consider three additional points. First, as I have
previously pointed out, the authors of cppreference.com think the code
is correct and I suspect they know more about it than you do.
Secondly, as I have also pointed out, Stroustrup's TC++PL contains a
similar example (using std::uninitialized_copy()) and I suspect he
knows more about it than you do.
 
Thirdly you might then respond "that's an argument ad verecundiam", and
indeed it is, although I have also given you the argument on the facts.
Let me alternatively appeal to common sense and give an example of a
case where you cannot feasibly directly use the return value of
placement new (as opposed to the buffer value passed to it) in the way
you have previously suggested. This is the very common idiom of using
an array of unsigned char or std::byte to construct an uninitialized
buffer for objects of class type T, let's say to make a fixed-size
circular buffer of up to 100 T elements. For circular buffers you
would commonly construct an element in the buffer using placement new,
and then, when you subsequently copy/move the element from the buffer,
destroy the buffer element by calling its destructor explicitly. You
could not however store the pointer value returned by the application of
placement new without keeping a separate array of T* pointers to shadow
each of the possible 100 or less T elements in the array of unsigned
char at any one time. That would be a ridiculous waste of memory and
even if you doubt the competence of cppreference.com and/or Stroustrup,
you must surely think that the authors of the C++ standard would have
taken the effort to cover this, particularly given that the standard
explicitly permits the construction of objects in arrays of unsigned
char or std::byte.
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

Thursday, February 27, 2020

Digest for comp.lang.c++@googlegroups.com - 6 updates in 2 topics

Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo>: Feb 27 12:24AM -0500

Melzzzzz wrote:
>> reinterpret_cast (in this case, from the pointer to e or its first element) to
>> obtain the pointer to that complete object (created by the placement new).
 
> Without that you couldn't implement allocator in C++...
I think gcc-9.2 C++ Standard Library implements std::allocator without using
reinterpret_cast (some other non-standard allocators provided with the library
do use it but that does not invalidate the point).
 
Of course above I assume that the allocation functions "... void* operator new
..." are not parts of std::allocator implementation but underlying low-level
implementation details.
 
On a side note, it is telling that reinterpret_cast is not used in this
implementation even though it is a special library packed with the compiler and
as such it is the one library that _could_ use the compiler's
implementation-specific behavior (including that of reinterpret_cast) without
running afoul of the Standard.
 
Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo>: Feb 27 12:50AM -0500

Öö Tiib wrote:
>> development, of all things.
 
> I have observed same thing. Hiring C++ programmers has became
> hard.
Hiring a COBOL or FORTRAN-66 programmer could be even harder :-). Just kidding.
 
> (or outright web servers) into their embedded equipment while
> being resistant to increase bills of materials.
> Can be raise in usage of hand-held stuff and battery life of such.
I think unexpectedly relevant to this is David Gross's talk on C++
micro-benchmarking at https://www.youtube.com/watch?v=Czr5dBfs72U.
 
Hopefully listening to the talk will be worth it for some people here for its
main subject; but it is also preceded with a number of reasons for why we may
want to write in C++ with one being saving the world the from climate change.
 
I found it ironic but also convincing (of course it is easy to get convinced
that you are saving the world so I might be biased here):
 
In a typical infrastructure of a tech firm running few hundreds or thousands
power-hungry UNIX servers replacing Java (not to mention Python and such) with
decently written C++ code can easily make possible to retire two-third of them.
 
Maciej Sobczak <see.my.homepage@gmail.com>: Feb 26 11:55PM -0800

> I don't see what's curious about it though: C++ is a drop-in
> replacement for C from a runtime perspective.
 
Unless you have messed up your run-time so much (or you have so little of it), that the replacement is not possible at all.
 
This is usually not a concern on desktop or on server, where developers treat the runtime as a black-box part of the development environment, but occasionally happens in the world of embedded systems, where engineers are more keen hacking their own linker scripts or startup sequences. If you mess it up to the extent that nobody wants to support it any longer, then introducing the programming language that is much more demanding with its constructors of static objects, virtual function tables, exceptions and what not, might be a challenge that nobody will want to take. I can imagine teams getting stuck like this forever.
 
But fortunately, hardware vendors provide complete IDEs that handle both C and C++ reasonably well, so this should not be a concern for new projects. As a personal story, I have recently managed to port a mature high-level C++ messaging library to several embedded platforms without any issues caused by the language, the only challenge being the peculiarities of the target real-time operating systems and their network stacks. This positive porting experience allows me to treat C++ as a perfectly validated solution for embedded systems and I expect to see more of it in this space.
 
--
Maciej Sobczak * http://www.inspirel.com
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Feb 27 11:21AM

On Thu, 27 Feb 2020 00:24:15 -0500
> as such it is the one library that _could_ use the compiler's
> implementation-specific behavior (including that of reinterpret_cast) without
> running afoul of the Standard.
 
You keep going on about reinterpret_cast. To remind you, the code in
question which you previously said had undefined behaviour, and you now
seem to say has implementation defined behaviour, is this:
 
struct Y {int z;};
alignas(Y) std::byte s[sizeof(Y)];
Y* q = new(&s) Y{2};
const int h = std::launder(reinterpret_cast<Y*>(&s))->z;
 
So just what behaviour do you think is implementation-defined here?
Some uses of reinterpret_cast can have implementation defined behaviour
(the mapping of pointer to integer, and the effect of conversions
between object pointer and function pointer) but these are not relevant
here.
 
Just repeating yourself does not make what you say true. Let's have a
proper explanation, preferably with reference to some authoritative
work[1].
 
Chris
 
[1] There are some issues to consider in addition to aliasing and
alignment previously mentioned (for example, what address does the
global placement new operator return by reference to the address of its
void* argument). Unfortunately you are on the wrong side of that one
also.
Rosario19 <Ros@invalid.invalid>: Feb 27 10:56AM +0100

On Thu, 27 Feb 2020 10:43:09 +0100, Rosario19 wrote:
 
>On Thu, 27 Feb 2020 10:39:20 +0100, Rosario19 wrote:
 
if someone want reduce humans to 0? this virus would be ok:
 
1 phase
7 14 30 60 360 days of asintomatic spread exponential
 
2 phase
the ill, with reinfetion or reemerge and the death 100%
 
in this wrost case the only is auto quarantine for enought time
 
there is something as 2 week i prepare go to supermarket etc
i for me begin one quarantine 2 months with 0 exit out
but i have some problem possible i have to exit too
Rosario19 <Ros@invalid.invalid>: Feb 27 11:35AM +0100

On Thu, 27 Feb 2020 10:56:06 +0100, Rosario19 wrote:
 
 
>there is something as 2 week i prepare go to supermarket etc
>i for me begin one quarantine 2 months with 0 exit out
>but i have some problem possible i have to exit too
 
visto che le mascherine nn funzionano al 100%
 
visto che la quarantena nn funziona poichè il virus si nasconde
nell'organismo e riemerge (ipotesi) inoltre casi di 30gg , 42 gg
asintomatici
 
visto che i test hanno percentuali elevati di falsi negativi almeno in
Cina del 50% cioe uno su due
(in pratica basta 1 su 10000 e la malattia si diffonde
esponenzialmente lo stesso)
 
vista la Cina che si blocca tutta (i morti nn li contano x me)
 
l'unica era bloccare tutto ,
frontiere, rifuggiati, migranti, turisti
aerei, navi tutto...
 
nn lo hanno fatto,
si prenderanno le loro responsabilità (se qualcuno in italia rimane
vivo)
 
spero che sia solo influenza ma da come si comporta la Cina nn sembra
proprio l'influenza
 
Preghiamo Dio che ce la possiamo scappottare, magari se inizia la
primavera in aticipo con piu caldo e al virus gli viene difficile
circolare ,
anche se potrebbbe rimanere nel corpo dei portatori sani , che si
potranno successivamente ammalare o diffondere il virus.
 
x parte mia vorrei fare una quarantena di 3 mesi, o 2 mesi, con 0
uscite è l'unica che rimane poiche si diffonde anche da quelli che
credono di stare bene,
o che i tamponi, i test, sbagliando, fanno risultare negativi.
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

Digest for comp.programming.threads@googlegroups.com - 2 updates in 1 topic

aminer68@gmail.com: Feb 26 09:19AM -0800

Hello,
 
 
About C++ templates and Delphi generics and code bloat..
 
I have just read the following webpage about Delphi generics(that are like templates of C++) and code bloat:
 
https://boyet.com/blog/delphi-oriented-generics-or-what-a-dog/
 
 
I think Julian M Bucknall is way too pessimistic about Delphi, because
what that means is: if you have Unit1.pas and Unit2.pas and both are using TList<Integer> both Unit1.dcu and Unit2.dcu have the binary code for TList<Integer> compiled in, but only when compiling your binary the linker will remove duplicates. So i think Delphi is the same as C++, because notice that C++ also has code bloat with templates:
 
So read in the following it says:
 
"In C++ code bloat occurs because compilers generate code for all templated functions in each translation unit that use them. Back in the day the duplicate code was not consolidated resulting in "code bloat". These days the duplicate code can be removed at link time."
 
Read here:
 
https://stackoverflow.com/questions/24333345/how-does-template-cause-the-code-bloat-in-c
 
 
Thank you,
Amine Moulay Ramdane.
Bonita Montero <Bonita.Montero@gmail.com>: Feb 26 07:06PM +0100

> "In C++ code bloat occurs because compilers generate code for all templated functions in each translation unit that use them. Back in the day the duplicate code was not consolidated resulting in "code bloat". These days the duplicate code can be removed at link time."
 
"These days" - it has never been different !
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.programming.threads+unsubscribe@googlegroups.com.

Wednesday, February 26, 2020

Digest for comp.lang.c++@googlegroups.com - 19 updates in 5 topics

cdalten@gmail.com: Feb 26 06:39AM -0800

On Sunday, February 23, 2020 at 6:50:13 AM UTC-8, Bonita Montero wrote:
> > I have posted just a few posts here, don't worry this is my last post in this newsgroup of C++
 
> Go to a doctor.
> You're bipolar and you don't have control over yourself.
 
Hey, I'm bipolar, and I can't control myself when Dan Cross tells me that he is wearing fishnet stockings, but like, I spam every groups all hours of the day. Instead, I just troll comp.lang.c -_-
cdalten@gmail.com: Feb 26 06:53AM -0800


> > Go to a doctor.
> > You're bipolar and you don't have control over yourself.
 
> Hey, I'm bipolar, and I can't control myself when Dan Cross tells me that he is wearing fishnet stockings, but like, I spam every groups all hours of the day. Instead, I just troll comp.lang.c -_-
 
er I DON'T spam. This is because I have this thing known as a job that gets in the way of any attempt at spamming.
queequeg@trust.no1 (Queequeg): Feb 26 09:17AM


> Yes, I would say it is spamming when you swamp a group with hundreds of
> posts that no one is interested in and effectively destroy that group.
 
I guess that every sane poster already has this moron killfiled.
 
--
https://www.youtube.com/watch?v=9lSzL1DqQn0
"Öö Tiib" <ootiib@hot.ee>: Feb 26 01:54AM -0800

On Wednesday, 26 February 2020 11:17:25 UTC+2, Queequeg wrote:
 
> > Yes, I would say it is spamming when you swamp a group with hundreds of
> > posts that no one is interested in and effectively destroy that group.
 
> I guess that every sane poster already has this moron killfiled.
 
Every sane poster should care that people interested in C++ see
walls of non-topical nonsense from Amine Moulay Ramdane
and so go search for some other forum.
cdalten@gmail.com: Feb 26 06:36AM -0800

On Wednesday, February 26, 2020 at 1:17:25 AM UTC-8, Queequeg wrote:
> > posts that no one is interested in and effectively destroy that group.
 
> I guess that every sane poster already has this moron killfiled.
 
> --
 
I didn't add him to my killfile, because for some strange reason, I thought this guy was somehow technically literate. But after I saw him failing to make the distinction between a Vector and a Vector Matrix when talking about a paper that he read on MIT, I came to the conclusion that the guy isn't even that literate.
 
For the non Math people that roam here, in general a vector remains invariant under a transformation whereas the components of the vector components aren't. And as far I understand things, the reason why both a vector and a vector matrix are sometimes uses interchangeably is because both appear to be the same when the basis of the vector spaces are all at 90 degrees?. Ie, orthonormal?
 
I guess I thought Ramine, the guy claims to know all this stuff, and like, reads all these research papers, would have been slightly aware of this subtle but important distinction.
James Kuyper <jameskuyper@alumni.caltech.edu>: Feb 26 09:43AM -0500

On 2/26/20 4:54 AM, Öö Tiib wrote:
...
> Every sane poster should care that people interested in C++ see
> walls of non-topical nonsense from Amine Moulay Ramdane
> and so go search for some other forum.
 
Is there anything that you or any of the rest of us can do to change
this? If so, please do (and let me know too - I'd like to help). If not,
there's not much point in getting upset about it.
cdalten@gmail.com: Feb 26 06:46AM -0800

On Wednesday, February 26, 2020 at 6:43:33 AM UTC-8, James Kuyper wrote:
 
> Is there anything that you or any of the rest of us can do to change
> this? If so, please do (and let me know too - I'd like to help). If not,
> there's not much point in getting upset about it.
 
I don't know if you also have me blocked, but he has had a few of his accounts suspended for "abuse". The problem is that he gives in a rest for like maybe 12 hours. After that, he creates a new account and just starts up again.
Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo>: Feb 25 11:08PM -0500

Chris Vine wrote:
> * there is no smaller array object that satisfies these constraints.
 
> The way you create an object in storage associated with another object
> of array type is with placement new.
 
I think we are fully on the same page about using placement new.
 
All I am saying is that I do not see how the Standard allows using
reinterpret_cast (in this case, from the pointer to e or its first element) to
obtain the pointer to that complete object (created by the placement new).
Melzzzzz <Melzzzzz@zzzzz.com>: Feb 26 05:03AM


> All I am saying is that I do not see how the Standard allows using
> reinterpret_cast (in this case, from the pointer to e or its first element) to
> obtain the pointer to that complete object (created by the placement new).
 
Without that you couldn't implement allocator in C++...
 
--
press any key to continue or any other to quit...
U ničemu ja ne uživam kao u svom statusu INVALIDA -- Zli Zec
Svi smo svedoci - oko 3 godine intenzivne propagande je dovoljno da jedan narod poludi -- Zli Zec
Na divljem zapadu i nije bilo tako puno nasilja, upravo zato jer su svi
bili naoruzani. -- Mladen Gogala
Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo>: Feb 26 12:54AM -0500

Chris Vine wrote:
> seems to me that you are just plucking this out of the air. Leaving
> aside std::launder, this is very well established code. If it didn't
> work
I am not saying it does not work. I am saying the behavior of this code is not
specified by the Standard. I am not alone at this either. If you can deduce from
the Standard that this code is well defined, I am very eager to know your deduction.
 
> there would be no point in having placement new (you couldn't use
> it in uninitialized memory returned by std::malloc() or operator new()
> either).
Why? You can use it in at least the following ways:
 
1. Placement operator new, as any other, returns a pointer to the object created
(see 7.6.2.7-5) -- you can use the return value.
2. Placement operator new can be used as in the example from the Standard for
launder I cited -- to create an object in a space occupied by an object of a
similar type to which you already hold a pointer. Then you can continue using
that pointer to access the new object, often directly and sometimes you will
have to use it via std::launder (under the conditions well described by the
Standard).
3. Placement operator new can be used to initialize a member (including that of
a union) or an array element of similar type and that member can then be accessed.
 
There may be other well-defined uses, too -- I am not claiming that the above
list is exhaustive.
 
> is concerned with the preconditions to using std::launder (which would
> be met here) and the effects thereof, but not with the circumstances in
> which §6.8/8 of C++17 requires the use of std::launder.
 
I disagree. I apologize, I do not have the 2017 standard, only C++20 draft n4849
so my numeration is different from yours. I completely cited the description I
have in the previous post. There the preconditions are specified in a
(normative) paragraphs 17.6.4-1 and 2 and the explanation on why you might use
it is in (non-normative) Note in 17.6.4-5. The (non-normative) example 17.6.4-6
fully agrees with the text of the Note.
 
I think that I correctly match the requirements you refer to paragraph 8 of
6.7.3 Lifetime in n4849., namely these 4 conditions (8.1 - 8.4) that I think are
well covered by the example from the launder spec I copied to my previous post;
also the example below those conditions seems to confirm my conclusions):
 
8 If, after the lifetime of an object has ended and before the storage which the
object occupied is reused or
released, a new object is created at the storage location which the original
object occupied, a pointer that
pointed to the original object, a reference that referred to the original
object, or the name of the original
object will automatically refer to the new object and, once the lifetime of the
new object has started, can be
used to manipulate the new object, if:
(8.1) — the storage for the new object exactly overlays the storage location
which the original object occupied,
and
(8.2) — the new object is of the same type as the original object (ignoring the
top-level cv-qualifiers), and
(8.3) — the original object is neither a complete object that is const-qualified
nor a subobject of such an object,
and
(8.4) — neither the original object nor the new object is a
potentially-overlapping subobject (6.7.2).
 
[Example:
 
struct C {
int i;
void f();
const C& operator=( const C& );
};
const C& C::operator=( const C& other) {
if ( this != &other ) {
this-> ~ C(); // lifetime of *this ends
new (this) C(other); // new object of type C created
f(); // well-defined
}
return *this;
}
 
C c1;
C c2;
c1 = c2; // well-defined
c1.f(); // well-defined; c1 refers to a new object of type C
 
 
— end example]
 
 
please note that launder is nowhere to be found and the comments say that the
code using new object is well-defined. All I am trying to say that the
conditions for the pointer to the old object to be valid for accessing the new
object are quite broad and the launder was introduced to allow compiler
optimizations in cases when it cannot easily determine that the object may have
been replaced.
 
 
> i. By virtue of the implicit decay of arrays to pointers, is the array
> name, when combined with the pointer arithmetic used in accessing array
> members, a "pointer that pointed to the original object".
I believe so.
 
> ii. If so, does it cease to be so if (as above) the type of the buffer
> element type (std::byte) is different from the type constructed in it
> by placement new (type Y)?
I believe so. After the new object of type Y is created, the old object (e.g an
array of bytes is gone. The pointer to the old object, however, still represents
"the address of the storage location" that the old object occupied -- until the
storage is released and can be used in limited ways as explained in paragraph 6
ibid (e.g. "using the pointer as if the pointer were of type void* is
well-defined").
> for the first time? (On the face of it §6.8/8 is concerned with
> constructing a replacement object in initialized memory after the
> lifetime of the previous object has ended).
 
I think you are correct. The whole purpose of paragraph 8 seems to be to define
when one can use a pointer or reference to or the name of the original object --
and there is no original object if the memory is uninitialized. I think the
paragraph 6 specifies what can be done with / is guaranteed for the pointer to
uninitialized memory.
Juha Nieminen <nospam@thanks.invalid>: Feb 26 08:18AM

> you, or because they think other languages are better in other ways, is
> difficult to say. Probably factors such as garbage collection,
> developer support and type safety are also relevant.
 
In my own professional experience demand for modern C++ expertise has been
raising. This is particularly, and curiously, so especially in embedded
development, of all things.
Maciej Sobczak <see.my.homepage@gmail.com>: Feb 26 12:56AM -0800

> And the relative use of C++ in projects has dropped in the past 20
> years also.
 
The interesting part in this observation is the word "relative".
But do you have any data (I don't) on *absolute* numbers?
Because the fact that other technology niches emerged in the mean time, with their own technologies, does not necessary mean that the demand for C++ diminishes.
It might also be the case that infrastructure development (which is a natural domain of C++) is concentrating in the hands of few big companies. So that C++ becomes a technology for Googles and Facebooks, but not necessarily for the average man-and-his-dog startup. So the social coverage of C++ my be changing, but not necessarily the total numbers.
Of course, it's difficult to get the actual data.
 
> you, or because they think other languages are better in other ways, is
> difficult to say. Probably factors such as garbage collection,
> developer support and type safety are also relevant.
 
My impression is that on a mass scale, such technical issues are not decision factors. People are writing Android apps in Java (or whatever they are writing in this week) not because of their careful and well-informed considerations of UB and GC, but because this is what this whole ecosystem is pushing on them. They didn't choose Java as a language, but they chose Android as a target.
 
I agree with Juha's other comment about the curiously rising presence of C++ in the embedded domain. At least all hardware vendors provide C++-capable development environments to enable such mainstream adoption and with the exploding functionality of embedded devices (everything is IoT, AI, and whatnot) this might be just unavoidable. Which is certainly good for the C++ community.
 
--
Maciej Sobczak * http://www.inspirel.com
Jorgen Grahn <grahn+nntp@snipabacken.se>: Feb 26 09:14AM

On Wed, 2020-02-26, Maciej Sobczak wrote:
...
 
> mainstream adoption and with the exploding functionality of embedded
> devices (everything is IoT, AI, and whatnot) this might be just
> unavoidable. Which is certainly good for the C++ community.
 
Yes. I don't see what's curious about it though: C++ is a drop-in
replacement for C from a runtime perspective.
 
/Jorgen
 
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
"Öö Tiib" <ootiib@hot.ee>: Feb 26 01:47AM -0800

On Wednesday, 26 February 2020 10:18:27 UTC+2, Juha Nieminen wrote:
 
> In my own professional experience demand for modern C++ expertise has been
> raising. This is particularly, and curiously, so especially in embedded
> development, of all things.
 
I have observed same thing. Hiring C++ programmers has became
hard. Can be that the schools prepare less of them.
Can be that C++ has became too complex to learn on your own.
Can be tendency of equipment manufacturers to make IOT
(or outright web servers) into their embedded equipment while
being resistant to increase bills of materials.
Can be raise in usage of hand-held stuff and battery life of such.
Can be the hipster culture of people wanting to have
special, customized precisely matching their personality.
Can be more effort needed against platform providers artifically
causing issues against usage of C++. Can be that the modern
snow-flake people just are useless as engineers.
Whatever it is, hiring at least half-decent C++ programmers has
became all harder and harder.
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Feb 26 12:57PM

On Tue, 25 Feb 2020 23:08:18 -0500
 
> All I am saying is that I do not see how the Standard allows using
> reinterpret_cast (in this case, from the pointer to e or its first element) to
> obtain the pointer to that complete object (created by the placement new).
 
I do not see how you think the standard does not allow using
reinterpret_cast in this case.
 
The standard provides that an object pointer can be converted to an
object pointer of a different type using reinterpret_cast. Leaving
aside lifetime issues involving std::launder, the problem with doing so
is two-fold. First it might result in incorrect alignment. Secondly it
might break C++'s aliasing rules by type punning. Neither occurs here.
alignas is used so alignment is correct. And there is no type punning:
there is an object of type Y (as created by placement new) at the
address in question. There would be type punning if you tried to use
the std::byte array to access the Y object without a reinterpret_cast,
say to examine individual bytes of the object, although as it happens
that is type punning which is blessed by the standard - §6.10/8.8 of
C++17.
 
You seem to have something wrong with your mental picture of this.
Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo>: Feb 26 01:07AM -0500

Chris M. Thomasson wrote:
>> 2023 when it really does not matter :-).
 
> Fwiw, what I get from the talk is that its better have a ctor and dtor, or else
> its undefined regardless?
My understanding of it was that the object should be created so constructor
should be called as part of that (the constructor implicitly defined by the
implementation should do, too) before using it (to put it in another way, no
amount of pointer casting and arithmetic will help to make the code using the
resulting pointer well defined if an object to which the pointer is trying to
point is not created)
Tim Rentsch <tr.17687@z991.linuxsc.com>: Feb 25 04:14PM -0800


>> Why not just this? (size_t)-1 /2 +1
 
> Because I didn't think of it before you posted
> it, Tim. :-)
 
Thank you for that Dan. It's good to see you back
in the newsgroups again.
cdalten@gmail.com: Feb 25 06:18PM -0800

Since Dan Cross has me blocked because I called him out for the wife beater that he is, let me try to fill you in on my Cross has been MIA.
 
Background. Dan is a Math guy who used to serve in the USMC. At the time he was dating some Russian woman. They broke up because he got tired of her being the "man" in the relationship. Now let's fast forward. He found some chick from the Gaza Strip that was desperate enough to date him. They've stuck together because she let's him be the man in the relationship. They even have a kid! He also likes the fact that he can beat his gf. Whereas with the Russian woman, well, everytime that he got pissed off, she basically beat his ass. This despite that fact that he was in the USMC!
 
These days he spends a lot of time on arbornet.org and grex.org. He goes under the name of cross on both of these sites. He prefers to hang out there because both systems are dominated by fat, middle aged, balding white men. He talks to the menz on these sites all the time just in case his current girlfriend finds a real man. Why? So he could date one of these guys!!!
 
Dan Cross isn't getting any younger. It's now getting to the point where he will settle down with anything on two legs. This could be male, female, or shemale.
cross@spitfire.i.gajendra.net (Dan Cross): Feb 26 02:22AM

In article <86tv3e9pc4.fsf@linuxsc.com>,
>> it, Tim. :-)
 
>Thank you for that Dan. It's good to see you back
>in the newsgroups again.
 
Thanks, Tim! It's nice to be reading.
 
- Dan C.
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

Tuesday, February 25, 2020

Digest for comp.lang.c++@googlegroups.com - 24 updates in 6 topics

Bonita Montero <Bonita.Montero@gmail.com>: Feb 18 06:46PM +0100

> What good reasons are left for a literal goto? I can see it in C for
> error handling (because it lacks exceptions) - in C++ there is hardly
> a good reason IMHO.
 
Even MISRA:C 2012 allows gotos if they go forward.
Tim Rentsch <tr.17687@z991.linuxsc.com>: Feb 25 07:56AM -0800


> Hmm, can't one simply compute:
 
> ~(size_t)0 ^ (~(size_t)0 >> 1)
 
> ?
 
Why not just this? (size_t)-1 /2 +1
cross@spitfire.i.gajendra.net (Dan Cross): Feb 25 10:00PM

In article <86y2sqace9.fsf@linuxsc.com>,
>Why not just this? (size_t)-1 /2 +1
 
Because I didn't think of it before you posted
it, Tim. :-)
 
- Dan C.
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Feb 25 12:34AM

On 24 Feb 2020 22:53:17 GMT
> > Ken Thompson.
 
> There's something wrong with that story: according to Wikipedia, Go
> was designed in 2007.
 
Here's a varbatim extract from what Rob Pike said about it in a talk in
2012 (text licensed by him under the Creative Commons Attribution 3.0
License). Please don't argue with me about whether he is right or not:
take it up with him if you feel strongly about it. (I happen to think
C++11 was pretty good.)
 
Back around September 2007, I was doing some minor but central work
on an enormous Google C++ program, one you've all interacted with,
and my compilations were taking about 45 minutes on our huge
distributed compile cluster. An announcement came around that there
was going to be a talk presented by a couple of Google employees
serving on the C++ standards committee. They were going to tell us
what was coming in C++0x, as it was called at the time. (It's now
known as C++11).
 
In the span of an hour at that talk we heard about something like 35
new features that were being planned. In fact there were many more,
but only 35 were described in the talk. Some of the features were
minor, of course, but the ones in the talk were at least significant
enough to call out. Some were very subtle and hard to understand, like
rvalue references, while others are especially C++-like, such as
variadic templates, and some others are just crazy, like user-defined
literals.
 
At this point I asked myself a question: Did the C++ committee really
believe that was wrong with C++ was that it didn't have enough
features?
 
***
 
But the C++0x talk got me thinking again. One thing that really
bothered me—and I think Ken and Robert as well—was the new C++ memory
model with atomic types. It just felt wrong to put such a
microscopically-defined set of details into an already over-burdened
type system. It also seemed short-sighted, since it's likely that
hardware will change significantly in the next decade and it would be
unwise to couple the language too tightly to today's hardware.
 
We returned to our offices after the talk. I started another
compilation, turned my chair around to face Robert, and started asking
pointed questions. Before the compilation was done, we'd roped Ken in
and had decided to do something. We did not want to be writing in C++
forever, and we—me especially—wanted to have concurrency at my
fingertips when writing Google code. We also wanted to address the
problem of "programming in the large" head on, about which more later.
Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo>: Feb 25 02:00AM -0500

Chris Vine wrote:
> // and does not point to a Y object
> const int g = q->z; // OK
> const int h = std::launder(reinterpret_cast<Y*>(&s))->z; // OK
IMHO it is UB type punning either way (i.e. with or without std::launder) (I
know that the code is from cppreference). Please see the whole argument in
"Union type punning in C++ redux thread". Regardless of whether you agree to my
position in there, I think in case of std::launder, the Standard is quite clear
(for a change) so citing the complete subsection (by n4849):
 
"
17.6.4 Pointer optimization barrier [ptr.launder]
template<class T> [[nodiscard]] constexpr T* launder(T* p) noexcept;
 
1 Mandates: !is_function_v<T> && !is_void_v<T> is true.
 
2 Preconditions: p represents the address A of a byte in memory. An object X
that is within its lifetime (6.7.3) and whose type is similar (7.3.5) to T is
located at the address A. All bytes of storage that would be reachable through
the result are reachable through p (see below).
 
3 Returns: A value of type T* that points to X.
 
4 Remarks: An invocation of this function may be used in a core constant
expression whenever the value of its argument may be used in a core constant
expression. A byte of storage is reachable through a pointer value that points
to an object Y if it is within the storage occupied by Y, an object that is
pointer-interconvertible with Y, or the immediately-enclosing array object if Y
is an array element.
 
5 [Note: If a new object is created in storage occupied by an existing object of
the same type, a pointer to the original object can be used to refer to the new
object unless its complete object is a const object or it is a base class
subobject; in the latter cases, this function can be used to obtain a usable
pointer to the new object. See 6.7.3. — end note]
 
6 [Example:
struct X { int n; };
const X *p = new const X{3};
const int a = p->n;
new (const_cast<X*>(p)) const X{5}; // p does not point to new object (6.7.3)
// because its type is const
const int b = p->n; // undefined behavior
const int c = std::launder(p)->n; // OK
— end example]
"
 
Please note:
 
a) the name of the section, std::launder is a [compiler -- IMHO] *optimization
barrier*.
 
b) that to call std::launder the type of the object currently in memory shall be
"similar" to the type argument of std::launder template and hence to the type to
which p points. Note that how exactly the p is received does not matter (so the
type of the object from which it was reinterpret_cast does not matter) -- it is
exactly the point of std::launder to "build" (see below) from the pointer to the
old object a pointer to the new object (of _similar type_ and through which all
bytes of the storage occupied by the new object shall be _reachable_) occupying
the same memory that the old object occupied before.
 
c) the [Note:]. In Library descriptions, Notes are informative rather than
normative so my guess it is here exactly and only to answer "why" question. The
Note claims that, in general the pointer to the old object can be simply used to
access the new object -- "unless its complete object is a const object or it is
a base class subobject" -- as I briefly cited above -- which case is exactly the
reason for launder to be called. [Note] hints at kinds of optimizations the
"Pointer optimization barrier" intends to prohibit: in particular I would
speculate that it needs to prohibit at least optimizing out reads via the old
pointer-to-const or pointer-to-base subobject that compiler otherwise could
replace with e.g. the values earlier loaded via the old pointer to registers
(the former -- by reasoning that the const object shall not have changed; and
the latter -- because the destruction and recreation of a derived object could
be not traceable or not required by the Standard to be traced by the compiler if
it can only see the code operating with a pointer to a base subobject of that
derived object).
 
d) finally, that the [Example] in the Standard is in direct and precise
correspondence with the [Note] -- as opposed to the example at cppreference.
Specifically, the [Example] does not use reinterpret_cast or static_cast
distractions but instead demonstrates how the pointer to the destroyed const
object can be used to build a pointer through which an object created later in
the same storage ("new object") could be safely accessed. (At runtime, such
"build" itself is probably no-op and the new pointer can very well have same
value and even occupy same memory location or a register as the old pointer --
but at compile time the compiler would know to build the code that actually
accesses the storage for new accesses via so built new pointer -- instead of
using the values read earlier via the old pointer and cached somewhere. In other
words, std::launder seems to be an explicit anti-aliasing of sort for similar
types).
 
 
Jorgen Grahn <grahn+nntp@snipabacken.se>: Feb 25 07:30AM

On Tue, 2020-02-25, Chris Vine wrote:
 
> Here's a varbatim extract from what Rob Pike said about it in a talk in
> 2012 (text licensed by him under the Creative Commons Attribution 3.0
> License).
 
[snip quote]
 
Thanks! It made more sense in his words.
 
> Please don't argue with me about whether he is right or not: take it
> up with him if you feel strongly about it. (I happen to think C++11
> was pretty good.)
 
So do I -- to me, it's mostly a polished C++98, supporting the same
things that C++98 did, only better. Although unlike Pike I don't care
about concurrency ...
 
I complained mostly because I didn't think work on (what became) C++11
had started in 2007, but thinking again of the C++0x name, of course
it had.
 
/Jorgen
 
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Feb 25 11:01AM

On 25 Feb 2020 07:30:10 GMT
> On Tue, 2020-02-25, Chris Vine wrote:
[snip]
 
> So do I -- to me, it's mostly a polished C++98, supporting the same
> things that C++98 did, only better. Although unlike Pike I don't care
> about concurrency ...
 
While I think that C++11 was pretty good - rvalue references and
variadic templates were like a breath of fresh air - and I can see the
point of concepts and modules in C++20, it seems to me that C++ is
becoming so complex that it is beyond the ability of the normal
programmer to come to grips with all of it. This results in bugs. C++
has grown as a loosely pinned set of features, not all of which are
consistent and which are a mess of corner cases where one edge meets
another. Some features look as if they were championed by dilletantes,
not by practising programmers. It lacks regularity and consistency.
C++ is not alone in complexity: Haskell for example is also complex and
difficult to grasp (although it is largely regular), but Haskell is not
a mainstream programming language like C++ is supposed to be.
 
This doesn't worry me especially. I use other languages also (not yet
rust), including functional languages, and enjoy them. However I do get
annoyed by gratuitous code-breaking things in C++, like needing to apply
std::launder to buffers updated with placement new. Surely we must all
have written circular buffers which construct elements in place with
placement new? What's the point with std::launder for heaven's sake -
the compiler can see you have used placement new, that necessarily
implies that the memory location concerned has been mutated, so when
code accesses the buffer with the correct cast to meet aliasing rules,
make sure the dereferenced values supplied are the correct ones. You
shouldn't need to burden the programmer with having to remember to use
std::launder to get the correct code generated.
 
I am not convinced even the experts, such as those at cppreference.com
or those on the standard committee, understand the rules on std::launder
and placement new. I notice that C++20 has now rowed back from C++17 on
some of this: in reponse to protestations, you no longer need to use
std::launder to access an object constructed by placement new by reason
of it having a const or reference member. However, nothing has changed
on using std::launder with aligned char[]/std::byte[] buffers. I am
still not 100% sure std::launder is required for this and that
cppreference.com is right on the point, but nor does anyone else seem to
be.
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Feb 25 12:13PM

On Tue, 25 Feb 2020 02:00:42 -0500
> know that the code is from cppreference). Please see the whole argument in
> "Union type punning in C++ redux thread". Regardless of whether you agree to my
> position in there,
 
I completely disagree with you that leaving aside std::launder it is UB,
so that does somewhat colour my view on the remainder of your views. It
seems to me that you are just plucking this out of the air. Leaving
aside std::launder, this is very well established code. If it didn't
work there would be no point in having placement new (you couldn't use
it in uninitialized memory returned by std::malloc() or operator new()
either). Something similar appears in Stroustrup's TC++PL.
 
> I think in case of std::launder, the Standard is quite clear
> (for a change) so citing the complete subsection (by n4849):
 
> 17.6.4 Pointer optimization barrier [ptr.launder]
[snip]
 
None of this deals with the issue now in question. §21.6.4 of C++17
is concerned with the preconditions to using std::launder (which would
be met here) and the effects thereof, but not with the circumstances in
which §6.8/8 of C++17 requires the use of std::launder. In the case
cited above, on the face of it there are a number of questions going to
the extent to which §6.8/8 of C++17 is relevant to begin with:
 
i. By virtue of the implicit decay of arrays to pointers, is the array
name, when combined with the pointer arithmetic used in accessing array
members, a "pointer that pointed to the original object".
 
ii. If so, does it cease to be so if (as above) the type of the buffer
element type (std::byte) is different from the type constructed in it
by placement new (type Y)?
 
iii. Does §6.8/8 have any relevance where, as in the case cited above,
placement new is used to construct an object in unninitialized memory
for the first time? (On the face of it §6.8/8 is concerned with
constructing a replacement object in initialized memory after the
lifetime of the previous object has ended).
Juha Nieminen <nospam@thanks.invalid>: Feb 25 01:51PM

> it seems to me that C++ is
> becoming so complex that it is beyond the ability of the normal
> programmer to come to grips with all of it.
 
This is something that has been being said, non-stop, for the past 20 years.
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Feb 25 01:55PM

On Tue, 25 Feb 2020 12:13:36 +0000
Chris Vine <chris@cvine--nospam--.freeserve.co.uk> wrote:
[snip]
> work there would be no point in having placement new (you couldn't use
> it in uninitialized memory returned by std::malloc() or operator new()
> either). Something similar appears in Stroustrup's TC++PL.
 
I see it is also specifically permitted by §4.5/3 of C++17:
 
If a complete object is created (8.3.4) in storage associated with
another object e of type "array of N unsigned char" or of type "array
of N std::byte" (21.2.1), that array provides storage for the created
object if:
 
* the lifetime of e has begun and not ended, and
* the storage for the new object fits entirely within e, and
* there is no smaller array object that satisfies these constraints.
 
The way you create an object in storage associated with another object
of array type is with placement new.
Melzzzzz <Melzzzzz@zzzzz.com>: Feb 25 01:57PM

>> becoming so complex that it is beyond the ability of the normal
>> programmer to come to grips with all of it.
 
> This is something that has been being said, non-stop, for the past 20 years.
Yeah, and response is very few use all of it :)
 
--
press any key to continue or any other to quit...
U ničemu ja ne uživam kao u svom statusu INVALIDA -- Zli Zec
Svi smo svedoci - oko 3 godine intenzivne propagande je dovoljno da jedan narod poludi -- Zli Zec
Na divljem zapadu i nije bilo tako puno nasilja, upravo zato jer su svi
bili naoruzani. -- Mladen Gogala
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Feb 25 02:40PM

On Tue, 25 Feb 2020 13:51:55 -0000 (UTC)
> > becoming so complex that it is beyond the ability of the normal
> > programmer to come to grips with all of it.
 
> This is something that has been being said, non-stop, for the past 20 years.
 
And the relative use of C++ in projects has dropped in the past 20
years also. Whether that's because people are put off by C++'s
complexity and proneness to having undefined behavior spring out to get
you, or because they think other languages are better in other ways, is
difficult to say. Probably factors such as garbage collection,
developer support and type safety are also relevant.
Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo>: Feb 25 12:26AM -0500

Bonita Montero wrote:
>> Care to pick one that is most readable in your opinion for me to demonstrate its
>> readability pitfalls?
 
> Pople able to manage to handle C++ can read either case good.
Popla manage not handle good.
Bonita Montero <Bonita.Montero@gmail.com>: Feb 19 07:28AM +0100

> I have never said it had bad readability. I said your "nice thing" serving
> no purpose was an obfuscation pretending to be simple while not being so. ...
Whoever finds the contradiction may keep it.
 
> return TSX_ABORTED_CAN_RETRY;
 
> return TSX_ABORTED_DONT_RETRY;
> }
 
That's a matter of taste.
Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo>: Feb 17 04:04PM -0500

Bonita Montero wrote:
>>> some nice  things like this "++(xyz == CMP ? a : b)" with it.
 
>> Now THAT is a) obfuscation and b) irrelevant to your TM idea.
 
> It's unusual, but readable, so no obfuscation.
It's not really unusual. You "nice thing" pretends to be simple (which
it is not) only because it's example code serving no useful purpose.
Your original code served useful purpose and you immediately found you
had to correct it. The correction made your conditional expression
slightly bulkier and the use of ternary operator (that was originally
reasonable) lost 95% of its initial appeal. It's no longer concise and
not too readable even though it is free of side effects as opposed to
your "nice thing" above. Readable code separates concerns and your "nice
thing" does the opposite.
Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo>: Feb 19 12:28AM -0500

Bonita Montero wrote:
>> your "nice thing" above. Readable code separates concerns and your "nice
>> thing" does the opposite.
 
> The code I've shown doesn't have a bad redability.
I have never said it had bad readability. I said your "nice thing" serving no
purpose was an obfuscation pretending to be simple while not being so. It would
be a bad idea (now I am saying "bad") to use it as an example to do anything useful.
 
Your original "transaction" code was rather readable although had an unnecessary
"else" clause made it more complex than necessary.
 
While fixing the bug your worsened the readability from ok to rather poor (again
I am not calling it "bad").
 
A better readable code for "transaction", after the bug fix and preserving your
preferences for indentation and braces but not new lines and using magic numbers
vs symbolic constants could be, for example:
 
enum TsxStatusCategory: int {
TSX_ABORTED_DONT_RETRY = -1,
TSX_ABORTED_CAN_RETRY = 0,
TSX_COMMITTED = 1
};
 
template<typename L>
inline
TsxStatusCategory
doTsxTransaction( L &lambda ) // function name should be a verb [clause]
{
unsigned code = _xbegin(); // unsinged is not unsigned BTW
 
if( code == _XBEGIN_STARTED )
{
lambda();
_xend();
return TSX_COMMITTED;
} // `else' served no purpose here other than obfuscation
 
if (code & _XABORT_EXPLICIT)
return TSX_ABORTED_DONT_RETRY;
 
if (code & _XABORT_RETRY)
return TSX_ABORTED_CAN_RETRY;
 
return TSX_ABORTED_DONT_RETRY;
}
 
 
> Yours has a bad readabiliy.
Yes, it does and as said earlier it is its point.
Bonita Montero <Bonita.Montero@gmail.com>: Feb 18 08:09AM +0100

> not too readable even though it is free of side effects as opposed to
> your "nice thing" above. Readable code separates concerns and your "nice
> thing" does the opposite.
 
The code I've shown doesn't have a bad redability.
Yours has a bad readabiliy.
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Feb 17 04:22PM -0800

> Hello,
 
> Here is my new invention of a scalable algorithm:
[...]
 
Have you ever use a verification program? Like, oh, say Relacy?
Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo>: Feb 25 12:03AM -0500

Öö Tiib wrote:
> to struct itself I already copy pasted. And aligned_storage
> is satisfying the alignment requirements of T so why you deny
> that Daniel's example is well-formed?
Because the above text requires that "there is an object b of type T (ignoring
cv-qualification) that is pointer-interconvertible (6.9.2) with a" for result to
be a pointer to b.
 
How can we deduce that the type std::aligned_storage<T,
some-align-greater-than-or-equal-to-alignof<T> >::type is
pointer-interconvertible with T (even ignoring cv-qualification)?
 
Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo>: Feb 25 12:11AM -0500

Pavel wrote:
 
> How can we deduce that the type std::aligned_storage<T,
> some-align-greater-than-or-equal-to-alignof<T> >::type is
> pointer-interconvertible with T (even ignoring cv-qualification)?
More precisely I should have asked: \
 
How can we deduce that *an object of type* std::aligned_storage<T,
some-align-greater-than-or-equal-to-alignof<T> >::type is
pointer-interconvertible with *an object of type* T (even ignoring
cv-qualification)?
 
 
Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo>: Feb 25 12:19AM -0500

Cholo Lennon wrote:
 
> Just for the record: there is a nice talk from CppCon 2019 about "Type punning
> in modern C++"
 
> https://youtu.be/_qzMpk-22cc
Thanks, it is a nice and somewhat funny talk. Among the others, there is a
chance that the OP's code will become legal in C++ 23 :-).
 
The guy is in "reinterpret_cast" camp but in the Q&A session he at least
acknowledges the existence of the "union" camp that believes that no use of
reinterpret_cast is legal for type punning. It seems someone from that other
camp wrote an article to disprove reinterpret_cast type punning .. funny I never
heard of it; will try to find and read it when idle i.e. probably also around
2023 when it really does not matter :-).
 
> Cholo Lennon
> Bs.As.
> ARG
 
-Pavel
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Feb 24 10:37PM -0800

On 2/24/2020 9:19 PM, Pavel wrote:
> camp wrote an article to disprove reinterpret_cast type punning .. funny I never
> heard of it; will try to find and read it when idle i.e. probably also around
> 2023 when it really does not matter :-).
 
Fwiw, what I get from the talk is that its better have a ctor and dtor,
or else its undefined regardless? Placement new and explicit dtor call
for properly aligned bytes.
Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo>: Feb 19 01:21AM -0500

Daniel wrote:
> return a.tag;
> }
> };
I think no: it is not allowed to inspect a.tag regardless of the constructor
used to construct V because `tag' is not a part of the common initial sequence
of either V::a and V::b or of V::a and V::c (I think the common initial sequence
is empty in both cases).
> {
 
> }
> };
I think no, for same reason.
 
I think changing implementation of tag() to either of { return b.tag; } or {
return c.tag; } would make the code valid (then of course having V::a member
would be unnecessary).
 
> Thanks,
> Daniel
 
FWIW,
 
-Pavel
Real Troll <Real.Troll@Trolls.com>: Feb 17 10:10PM

> material: Howard Hinnant (lead designer and author of move semantics),
> Jens Maurer, Arthur O'Dwyer, Geoffrey Romer, Bjarne Stroustrup, Andrew
> Sutton, Ville Voutilainen, Jonathan Wakely.
 
<https://herbsutter.com/2020/02/17/move-simply/>
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.