Stefan

11.1K posts

Stefan banner
Stefan

Stefan

@schteppe

Senior software engineer @StarStable. C++, physics, Jelly Mario, p2.js, cannon.js

Boden, Sverige Katılım Mart 2009
1.8K Takip Edilen3.9K Takipçiler
Stefan
Stefan@schteppe·
Stefan tweet media
ZXX
4
2
62
5.2K
Stefan
Stefan@schteppe·
The graph shows a conflicting dependency version problem: two versions of the same lib in your dependency graph. In C++ you may get UB or symbol clashes. In Rust it just works: the compiler includes both versions in the build but gives the symbols unique names to avoid clashes.
English
0
0
19
1.2K
Dmitrii Kovanikov
Dmitrii Kovanikov@ChShersh·
C++20 introduced for-range loops with an init-statement. I propose to support increment statements in for-range loops in C++29. I call it Default Enumerated Range loops, or DE-ranged loops for short.
Dmitrii Kovanikov tweet media
English
17
10
232
15.4K
Stefan
Stefan@schteppe·
@brain_nullptr What do you mean I shouldn’t write unit tests as C++ template code
English
1
0
4
93
refined
refined@brain_nullptr·
refined tweet media
ZXX
1
0
2
93
Stefan
Stefan@schteppe·
Soon…?
Stefan tweet media
English
6
0
34
2.2K
Stefan
Stefan@schteppe·
@ChShersh Should be utf8 compatible too 👍
English
1
0
7
324
Dmitrii Kovanikov
Dmitrii Kovanikov@ChShersh·
You're not a true C++ dev if you haven't written your own implementation of string 'trim' at least once. Here's a version with zero allocations.
Dmitrii Kovanikov tweet media
English
19
9
248
17.1K
Stefan
Stefan@schteppe·
@noel_bhe Much better than “[JIRA-ID] Jira ticket title written by user”
English
1
0
0
162
noel
noel@noel_bhe·
@schteppe 'Fix typo Applying this change will fix the typo'
English
1
0
2
170
Stefan
Stefan@schteppe·
Commit messages should end the sentence: “Applying this change will…”
English
5
0
19
2.7K
Stefan
Stefan@schteppe·
Even Bjarne thinks the template syntax is ugly. “…frequent and persistent user complaints that the C++ template syntax is verbose and ugly. I agree with those criticisms.”
English
6
1
57
4.6K
Stefan
Stefan@schteppe·
@kon_cuppy That’s a valid point, each of those variables/types store only what they are intended for. The decay comes in when you convert the array to pointer: you lose information about bounds.
English
1
0
0
72
Vbingus
Vbingus@kon_cuppy·
@schteppe Just think like this: When you declare a variable, it is to hold some value. sizeof will always show how much space is needed for the value you wanted to store in that variable. I personally don't like using the word "decay" for this because nothing is really changing or decaying
English
1
0
0
103
Stefan
Stefan@schteppe·
@gooficat there’s always a chance they’ll upgrade 😏
English
0
0
0
246
Stefan
Stefan@schteppe·
@Adriksh Clang warns about this by default. Use -Werror=format-security to fix this once and for all.
Stefan tweet media
English
0
0
2
98
Adriksh
Adriksh@Adriksh·
printf("%s", user_input) is safe, printf(user_input) is a vulnerability. printf interprets the first argument as a format string every % makes it read arguments that weren’t passed user-controlled format string = arbitrary memory reads (and with %n, writes) this class of bugs is old, and it still shows up
Adriksh tweet media
English
10
6
74
3.8K
Stefan
Stefan@schteppe·
@notsmv If you can use std::array then you should absolutely do it. 👍 But if you’re stuck with a C-style array like in the example, then you should wrap it in a std::span to make it bounds checked and safer.
English
1
0
3
270
smv
smv@notsmv·
@schteppe why std::span over std::array?
English
1
0
1
338
Stefan
Stefan@schteppe·
@ryanels If your branch has >48283 changed lines of code, you really need to merge more frequently
English
0
0
0
90
Ryan Els
Ryan Els@ryanels·
Can you relate? 😏
Ryan Els tweet media
English
7
10
241
6.9K
Stefan
Stefan@schteppe·
@noel_bhe Yeah… but operator[] is checked if you enable STL hardening. And you can use gsl::at()
English
1
0
0
141
noel
noel@noel_bhe·
@schteppe still hilarious that a span exists since c++20 and the checked access operation is getting introduced in c++26...
English
1
0
0
139
Stefan
Stefan@schteppe·
@noel_bhe That’s fine imo. Similar to unsafe blocks in Rust, just uglier.
English
2
0
1
515
noel
noel@noel_bhe·
@schteppe and then start crying because a span has no way for .at() so you have to disable the clang-tidy warning regarding unchecked array accesses
English
1
0
2
517