C++ quiz time! Assuming long long is 64 bits and double is IEEE754 double precision, what happens here:

long long n = 0x7fff'ffff'ffff'ffff;
double d = n;
long long m = d;
1
1
5
1,262
Replying to @zygoloid
The conversion to double rounds either up or down. C++ says it's implementation-defined which, but IEEE754's default rounding mode is Round-To-Nearest, which rounds up in this case, giving d == 2^63 exactly. The conversion back to m has UB due to being out of range for long long.
1
0
6
396
New C++ grammar ambiguity just dropped: godbolt.org/z/133c7fnos
Disambiguating between a C-style cast to a function type and a functional cast in parens can require statement / expression disambiguation to determine if you're parsing a lambda-expression or not.
3
10
66
4,334
Richard Smith retweeted
We have just released a new CppNow 2023 Conference Video!

Lightning Talk: Writing a Lookup Table in C++ - by @zygoloid - CppNow 2023

youtube.com/watch?v=SnKGD-…

#Lookuptables #Programming
0
4
27
6,112
Richard Smith retweeted
Definition-Checked Generics, Part 1: The Why & How - by @chandlerc1024, Josh Levenberg & @zygoloid

youtube.com/watch?v=FKC8WA…

#Coding #Cpp
1
3
18
6,459
How many more sides does a cube have than a square?
31
8
32
24,755
Richard Smith retweeted
what does this Python program output 👻

print(len([0x0for x in {1,2,1}]))
29
33
256
63,486
Richard Smith retweeted
I was in the room where it happened, because it happened to me. My name is Barbara Geller and I am one of the co-founders of the CopperSpice project. A horrifying incident happened on the last day of CppNow 2016 and this needs to be shared with the community. #cplusplus 1/
11
40
188
Richard Smith retweeted
Really excited we've been able to start sharing our experimental work on #CarbonLang with the wider C++ community.

That said, I'd suggest folks read up on the docs and maaaybe wait for our announcement keynote and Q&A from #CppNorth before leaping to too many assumptions. =]
Carbon, a successor language to C++ was announced at @CppNorth today by @chandlerc1024.

I'm very excited about this project's potential. You can learn more about Carbon and get involved on GitHub.

github.com/carbon-languag…
32
148
654
Richard Smith retweeted
Carbon, a new successor language from @chandlerc1024, @zygoloid, @gregcons and friends presented at @CppNorth! The keynote recording should be released on YouTube in a few days! ❤️
Live updates from @chandlerc1024's @CppNorth 2022 keynote! 1/ 🧵
2
11
55
Do the people who think 6÷2(2+1) is 9 also think that 2x÷2x is x²?
4
1
13
Richard Smith retweeted
I'm writing a talk on what's new in C++23, so while I'm doing that, here's a thread of new features:
15
176
823
Replying to @shafikyaghmour
@shafikyaghmour godbolt.org/z/37srqoWbc
```
int a = 1, b = 2, c = 3;
auto used = LOCALS_USED(a + b + c);
// Prints 1\n2\n3\n
std::apply([](auto& ...x){((std::cout << x << "\n"), ...);}, used);
```
Sadly MSVC-only.
2
1
7
Replying to @zygoloid
@shafikyaghmour Much of this ridiculousness is due to @chandlerc1024
3
0
3
Replying to @zygoloid
The context was: "wouldn't it be nice if assert-like macros could automatically show you the relevant local state".
0
0
1
Cheating at #wordle pro tip: type "five letter words" into Google and look at the suggested search queries.
1
0
4
Richard Smith retweeted
Cute C++ trick of the day: a few odd quirks of C++ allow you to create a registry of atomically-modified global variables that spookily jump over unreachable code: godbolt.org/z/v75zdG4fb

(Idea: @zygoloid. Yes, this is horrifying. Advanced version here: godbolt.org/z/vns6n5aa3)
10
24
174
I find the claim that this attack is a vulnerability in programming languages is especially bizarre. This is a vulnerability in some code review tools, if they don't properly show the reviewer the proposed changes, not in the programming languages.
I'm a bit unhappy with the degree of hyperbole and unreasonable fear mongering going on with krebsonsecurity.com/2021/11/trojan…

Interesting research, but it isn't new... Folks have been discussing unicode, bidi, and homoglyphs as forms of underhanded code bypassing review for many years.
1
1
21
Replying to @zygoloid
Something as simple and routine as a code review tool applying syntax highlighting will expose some of the attacks here. And unlike normal underhanded C, there is no plausible deniability in these attacks.
2
0
10
Richard Smith retweeted
x became associated with unknown quantities because the printer was running out of letter and choose x over y and z 🤯

From the book “Here’s Looking at Euclid”

#math
5
37
112
Suppose x = 2. Then
6 % 3x
gives:
6
1
7