Most active questions

23 votes
2 answers
4k views

Does excessive use of [[likely]] and [[unlikely]] really degrade program performance in C++?

The C++ standard [dcl.attr.likelihood] says: [Note 2: Excessive usage of either of these attributes is liable to result in performance degradation. — end note] I’m trying to understand what “...
Artyom Fedosov's user avatar
11 votes
1 answer
974 views

Jupyter Notebook extension Visual Studio Code "stuck in connecting to kernel"

I use Python 3.11.1 and Jupyter Notebook to run code selections or lines in the Interactive Window for debugging or coding purposes. A few days ago, on Thursday night, October 9th, 2025, everything ...
newbie's user avatar
  • 83
13 votes
3 answers
963 views

What is the size of std::array<T,0>?

Unlike C array, std::array is allowed to have zero length. But the current implementations differ in how std::array<T,0> is implemented, in particular the sizes of the object are different. This ...
Fedor's user avatar
  • 23.9k
6 votes
5 answers
220 views

How bad is a "controlled" signed int overflow and can it even be "controlled"?

Our school tasks us to reproduce the atoi function. Many students (I included) do it some way that causes an overflow in case of INT_MIN, which wraps around neatly so the function still works. We ...
m0d1nst4ll3r's user avatar
4 votes
4 answers
175 views

The scanf function in C language uses a width specifier for char

There is a code where I enter ABCDEFGH and press enter, and the final result is HGF. When I use debug mode to observe variables. When executing the first sentence input, x='A'. After the next step, x='...
Clara's user avatar
  • 141
14 votes
2 answers
328 views

Share buffer during a loop in Rust

Just stumble across Why we didn't rewrite our feed handler in Rust from databento And they say they cannot share a buffer during a loop. What would be the rust way to fix this without making copies of ...
mehh's user avatar
  • 149
2 votes
4 answers
192 views

Why does strlen(NULL) cause a compile-time warning, while my custom ft_strlen(NULL) only crashes at runtime?

I'm trying to reimplement the standard strlen function in C, and I'm closely replicating its behavior. I defined my function based on standard C declaration for strlen: size_t ft_strlen(const char *s);...
user31651582's user avatar
1 vote
3 answers
124 views

Constness of the pointer in parameter variable [closed]

Which function signature is a good practice to use, I will change the object that pointer points to but not change the pointer itself? void LimitMousePosition(Vector2* p_mousePosition) void ...
rand_program's user avatar
  • 1,228
2 votes
3 answers
161 views

Keyword keeps getting appended to input file even when it is present. How can I fix this?

In C++, I have written this code: #include <iostream> #include <fstream> #include <sstream> #include <stdbool.h> using namespace std; int main(int argc, char** argv){ ...
mini kids's user avatar
  • 137
2 votes
3 answers
151 views

What is the difference between a value and a memory address in x86_64 AT&T assembly language?

Novice here, with a frustratingly simple question. I'm trying to learn assembly and this has been a stumbling block for me for so long, I would really appreciate help with these concepts. Thanks so ...
Andrew Boone's user avatar
7 votes
2 answers
247 views

How do I follow "C.12 - Don’t make data members const or references in a copyable or movable type" while keeping track of some const value?

When I have some const members variables in my class, I would like to know how to respect core guideline C.12 to keep a default copy-assignment operator. C.12: Don’t make data members const or ...
kingsjester's user avatar
4 votes
6 answers
183 views

Correct interpretation of clause 6.5 Expressions in the draft C standard

I’m reading draft WG 14/N 3088, paragraph 6.5 Expressions, paragraph 7: 7 An object shall have its stored value accessed only by an lvalue expression that has one of the following types:98) — a type ...
Evgeny Ilyin's user avatar
3 votes
1 answer
276 views

How strong is the as-if rule in C++

As an exercice and side project I have started to write a runtime SIMD library in C++ that wraps around the intrinsics and that builds an expression tree. Each possible node in a tree must contain an ...
Johan Daniel's user avatar
2 votes
3 answers
189 views

Initialize char array with alphabet

struct Person { char name[40]; int age; }; int main() { struct Person people[15]; struct Person *p_Person = people; for (int i = 0; i < 15; i++) { //strcpy(p_Person-...
panci matika's user avatar
4 votes
1 answer
182 views

Deleting nullptr before creating the object in Qt code

I'm exploring OpenGL with Qt6, and I came across some of their examples. The thing that draws my attention from a C++ perspective is the following piece of code. delete m_program; // <-- is this ...
CroCo's user avatar
  • 5,879

15 30 50 per page
1
2 3 4 5
142