Wednesday, September 16, 2020

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

Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Sep 16 09:54PM +0100

On 16/09/2020 21:51, David Brown wrote:
 
> provides a summary that is easier to follow than the standards.
 
> MSVC is still wrong, since C++17 forces the evaluation order of <<
> expressions.
 
MSVC is only wrong if you choose language standard compiler setting of pre-C++17. Yes it was operator error. :/
 
/Flibble
 
--
¬
David Brown <david.brown@hesbynett.no>: Sep 16 10:53PM +0200

On 16/09/2020 22:32, Mr Flibble wrote:
 
> The problem was operator error: it helps if you change the compiler
> settings for the build configuration you are actually building.
 
> Sorry for the noise.
 
The thread made me think, let me make a mistake, let my mistake get
spotted, let me correct my mistake and learn a little more accurate
details. So I am glad for the noise here!
Juha Nieminen <nospam@thanks.invalid>: Sep 16 09:43PM


>> How so? C has weaker rules about expression evaluation sequencing than
>> C++ does and none that fix this issue with sequencing IO operations.
 
> You wouldn't write IO in that way in C, so the problem goes away.
 
Oh, so nobody ever writes things like
 
printf("%i,%i", a(), b())
 
in C?
 
Right...
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Sep 16 05:44PM -0400

On 9/16/20 4:47 PM, Ben Bacarisse wrote:
>> You wouldn't write IO in that way in C, so the problem goes away.
 
> You can write it so that the problem goes away in C++ too, so what was
> your point about switching C?
 
100% humor.
 
--
Rick C. Hodgin
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Sep 16 06:05PM -0400

On 9/16/20 5:43 PM, Juha Nieminen wrote:
> Oh, so nobody ever writes things like
> printf("%i,%i", a(), b())
> in C?
 
You tell me. Per the bug report he submitted to Visual Studio 2019:
 
int a(void)
{
return 1;
}
 
int b(void)
{
return 2;
}
 
int main(int argc, char* argv[])
{
// C++ way
std::cout << a() << b();
std::cout << std::endl;
// Reports 12
 
// C++ way
std::cout << (a() << b());
std::cout << std::endl;
// Reports 4
 
// C way
printf("%d\n", a() << b());
// Reports 4
 
return 0;
}
 
I only have Visual Studio 2003 on this computer, and it reports 12, 4,
and 4. It should be reporting 4, 4, and 4, in C++17.
 
C gets it right. C++ does too with a little help from its friends
(parenthetically speaking of course).
 
> Right...
 
See how easy it is to misunderstand something? You do it effortlessly.
You make it look easy. :-)
 
Actually, this would be a great teaching moment for Bonita. It
demonstrates that adding an extra set of parenthesis now and then
removes real-world code issues.
 
--
Rick C. Hodgin
Ben Bacarisse <ben.usenet@bsb.me.uk>: Sep 17 12:06AM +0100


>> You can write it so that the problem goes away in C++ too, so what was
>> your point about switching C?
 
> 100% humor.
 
It seems, from another post, that you did not understand the issue.
Hmm... or maybe that post was intended to be funny too. You might
consider marking, in some way, those posts that you'd like to be taken
seriously.
 
--
Ben.
Jorgen Grahn <grahn+nntp@snipabacken.se>: Sep 16 09:24PM

On Wed, 2020-09-16, Juha Nieminen wrote:
> Scott Lurndal <scott@slp53.sl.home> wrote:
>> Juha Nieminen <nospam@thanks.invalid> writes:
...
 
>> LTO generally solves that problem.
 
> LTO might help a bit in the future. It isn't very useful now, because
> compilers have no implementation of it.
 
Doesn't gcc's support (-flto) count? I haven't used it, but as I
understand it, it has been used by real software for years.
 
/Jorgen
 
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
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.

No comments: