- The unintended consequences of the 'auto' keyword - 4 Updates
- [Jesus Loves You] Inspirational woman - 2 Updates
- coronavirus COVID-19 - 1 Update
- The unintended consequences of the 'auto' keyword - 1 Update
"ΓΓΆ Tiib" <ootiib@hot.ee>: Apr 17 05:42PM -0700 On Friday, 17 April 2020 18:34:43 UTC+3, Ben Bacarisse wrote: > It may be simpler to fall into the trap in that case, but there are so > many others (~42_i16, 42_i16 + 10, 42_i16 << 1, printf("...", 42_i26)) > that knowing the underlying truth really helps. What really helps is to demand writing static_cast<int16_t>(-42) and to forbid usage of confusing user-defined integral literal operators of C++. Basically same as with octals. Useless, broken feature. Inevitably someone messes it up with "maintenance" and then wastes half day of his own wondering plus 15 minutes of mine too. |
Christian Gollwitzer <auriocus@gmx.de>: Apr 18 07:14PM +0200 Am 17.04.20 um 17:34 schrieb Ben Bacarisse: > It may be simpler to fall into the trap in that case, but there are so > many others (~42_i16, 42_i16 + 10, 42_i16 << 1, printf("...", 42_i26)) > that knowing the underlying truth really helps. I've designed a Matlab-like language, and the integer promotion rules also got me thinking. In the end I concluded that the base integer type (like int in C++) should be disctinct from the fixed-widths types and treated as an ideal integer. i.e., even if int== int32_t, the type promotion should not widen smaller types in this case. Therefore (in my language): auto x = -42i16; // x is -42i16 // unary - is defined for int16_t -> int16_t auto i = x + 1 // i is -41i16 // no promotion, because int is special auto j = x + 1i32; // j is -41i32 // promoted because int32_t has more bits than int16_t uint8_t byte=0; auto t = byte - 1; // t is 255u8 auto u = byte - 1i32; // u is -1i32 Christian |
Vir Campestris <vir.campestris@invalid.invalid>: Apr 18 09:53PM +0100 On 17/04/2020 14:41, James Kuyper wrote: > it predates C++, going all the way back to the early days of C. > Experienced C and C++ programmers are necessarily used to this problem, > and know how to deal with it. Interesting. I think I count myself as experienced - I've been writing C and C++ for nearly 40 years - and yet it's never bitten me. probably because short plus = 42; short minus = -plus; tends to end up as something like load 16 into register store into plus as 16 bit negate store into minus as 16 bit This case where auto minus = -plus; results in a 32 bit (or more!) size for minus is to me just another reason not to use auto where I can avoid it. Andy |
"ΓΓΆ Tiib" <ootiib@hot.ee>: Apr 18 01:59PM -0700 On Saturday, 18 April 2020 20:14:32 UTC+3, Christian Gollwitzer wrote: > // t is 255u8 > auto u = byte - 1i32; > // u is -1i32 Note that we can precisely enforce what mutations of 16 bit type happen and when (and with how explicit syntax) in C++, too. However we then have to make fully custom 16 bit types and to specify all the operators for those. C++ lets us to have types like "enum class I16 : int16_t {};" or like "struct I16 {int16_t v_;};" and army of operators. Both also have their (different) benefits, disadvantages and bear traps attached. For example with enum we can't have constructors, conversion operators, operator=, operator[], operator() or operator-> overloaded while with struct its layout-compatibility with int16_t or with enums that have int16_t as underlying type is far dimmer in standard. |
rick.c.hodgin@gmail.com: Apr 18 11:17AM -0700 [I love you too] This woman has an amazing story. She is almost completely deaf and gave up at one point. Please watch this video all the way through. She has some quirky parts, especially at the beginning, but it turns to amazing very quickly thereafter. America's Got Talent https://www.youtube.com/watch?v=lLLvxhOPdik&t=430s About Her Life https://www.youtube.com/watch?v=80oCOhlgjd4 See how Christ was at work in her life, even through the bad times, even when she had given up. We all need that rope she talks about. -- Rick C. Hodgin |
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Apr 18 08:46PM +0100 > See how Christ was at work in her life, even through the > bad times, even when she had given up. > We all need that rope she talks about. Fuck. Off. /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." |
killvirus@coronavirus.com: Apr 18 04:22PM coronavirus COVID-19 http://www.grex.org/~henced/coronavirus.html |
Udo Steinbach <trashcan@udoline.de>: Apr 18 10:13AM +0200 Am 2020-04-14 um 12:03 Uhr schrieb Juha Nieminen: > The (new meaning of the) 'auto' keyword can be extremely useful in many > situations Not so many. Lets ask another point of view, a foreign, code auditor for security reasons: https://blog.fefe.de/?ts=a0cf97c9 | Therefore it is important that you can see in the code if something is a | raw pointer. But you can't see when it's all auto. Then the poor auditor | has to run after every fucking line one by one and deduce the types | himself. Then auto is a denial of service against the auditor. ... and that tools do not help then. A nice lecture in How to shoot in the own foot. -- Fahrradverkehr in Deutschland: http://radwege.udoline.de/ GPG: A245 F153 0636 6E34 E2F3 E1EB 817A B14D 3E7E 482E |
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:
Post a Comment