Skip to main content
Filter by
Sorted by
Tagged with
0 votes
0 answers
28 views

C23 §5.2.5.3.3 [Characteristics of floating types <float.h>] paragraph 8 says: Floating types shall be able to represent signed zeros or an unsigned zero and all normalized floating-point ...
Jan Schultke's user avatar
  • 43.6k
2 votes
1 answer
72 views

Function templates are not allowed to have C language linkage: extern "C" { template<typename T> // error: template with C linkage void bad_f() {} } This is reasonable, as ...
yuri kilochek's user avatar
5 votes
1 answer
101 views

Both GCC and Clang reject extern "C" static void foo() {} but accept extern "C" { static void foo() {} } Aren't these supposed to be equivalent?
yuri kilochek's user avatar
8 votes
1 answer
637 views

Does the code below contain undefined behavior (UB)? struct A { int x; char y; }; int main() { std::vector<uint8_t> v(sizeof(A), 0); A* p = reinterpret_cast<A*>(v.data());...
Dmitriano's user avatar
  • 2,424
-2 votes
2 answers
224 views

Consider this example: extern void black_box_foo(); extern void black_box_bar(); int main(){ black_box_foo(); // #1 black_box_bar(); // #2 } #1 and #2 are functions whose definitions are ...
xmh0511's user avatar
  • 7,618
10 votes
3 answers
1k views

I've always assumed that "creating an object" is the same thing as "starting its lifetime" (and not the same thing as allocating storage for it). But I've recently been told that &...
HolyBlackCat's user avatar
3 votes
1 answer
139 views

The ECMAScript Language Specification states: Atomics are carved in stone: Program transformations must not cause any Shared Data Block events whose [[Order]] is seq-cst to be removed from the is-...
James Page's user avatar
17 votes
3 answers
874 views

I have a function template f, defining in its body a local class A with another nested class B. Both classes are not templates. Must I name the inner class as typename A::B or shorter variant A::B is ...
Fedor's user avatar
  • 24.7k
0 votes
1 answer
315 views

Consider this example: // thread A: start_transaction(); update_mysql(); commit_transaction(); // remove "key" from mysql tables remove_redis_cache("key"); // thread B: std::...
xmh0511's user avatar
  • 7,618
9 votes
1 answer
288 views

Here is a possibly incorrect program for communicating between a function and a signal handler that might interrupt it. Assume that HandleSignal has been arranged to run as a signal handler. The ...
jacobsa's user avatar
  • 7,817
14 votes
1 answer
857 views

Rust programs typically panic when you index into a slice with an out-of-bounds usize index. Is that panic actually guaranteed to happen? Can I rely on the panic when reasoning about the soundness of (...
Aljoscha Meyer's user avatar
14 votes
1 answer
357 views

Consider the following snippet: int main() { struct Local { virtual void foo() = 0; }; void (Local::* ptr)() = &Local::foo; } When compiling with C++20, GCC 13.3.0 and Clang 18.1.3 ...
OLEGSHA's user avatar
  • 728
4 votes
1 answer
220 views

In C, this is legal as far as I know (In C, does a pointer to a structure always point to its first member?). #include <stdio.h> typedef struct { char *name; int age; } A; typedef ...
Malyutin Egor's user avatar
0 votes
1 answer
162 views

[intro.execution] p8 says: Given any two evaluations A and B, if A is sequenced before B (or, equivalently, B is sequenced after A), then the execution of A shall precede the execution of B. ...
xmh0511's user avatar
  • 7,618
0 votes
1 answer
149 views

In order to examine object representation, the C++ standard provides https://timsong-cpp.github.io/cppwp/n4861/basic.lval#11: If a program attempts to access ([defns.access]) the stored value of an ...
Oersted's user avatar
  • 3,732
0 votes
1 answer
174 views

Consider this example: #include <atomic> #include <iostream> #include <chrono> #include <thread> #include <cassert> int main(){ std::atomic<int> val = {0}; ...
xmh0511's user avatar
  • 7,618
10 votes
1 answer
281 views

This is a multi-producer single-consumer implementation translated from Rust, for the language-lawyer question, rewriting it in C++ template<class T> struct Node{ std::atomic<Node*> ...
xmh0511's user avatar
  • 7,618
3 votes
1 answer
244 views

Can someone help me understand this part of cppreference? https://en.cppreference.com/w/cpp/language/default_comparisons.html Synthesized three-way comparison The synthesized three-way comparison of ...
a a's user avatar
  • 384
7 votes
1 answer
331 views

C11 introduced <stdalign.h>, which defined the macros alignas to _Alignas and alignof to _Alignof. Additionally, the feature test macros __alignas_is_defined and __alignof_is_defined are defined ...
DevSolar's user avatar
  • 71k
0 votes
0 answers
114 views

Based on cppreference, I was under impression that std::canonical and std::weakly_canonical return the input path if it is an absolute directory path to existing directory that has no dot, dot-dot ...
Fedor's user avatar
  • 24.7k
15 votes
1 answer
1k views

According to What are the reasons that extending the std namespace is considered undefined behavior?, adding anything to namespace std is Undefined Behavior, with some exceptions carved out, such as ...
Dominik Kaszewski's user avatar
6 votes
1 answer
165 views

In Cppreference the rules for pointer arithmetic include: If P points to the i-th element of an array object x with n elements, given the value of J as j, P is added or subtracted as follows: – P + J ...
Movoid's user avatar
  • 63
14 votes
2 answers
318 views

Consider this simple code. struct Foo { template <typename T> struct Bar { ~Bar(); }; }; with the out-of-line implementation template <typename T> Foo::Bar<T>::~...
Jody Hagins's user avatar
  • 28.6k
11 votes
1 answer
277 views

I wonder whether this piece of code should compile and what function it should call. The situation is that there is a struct whose name matches that of a template parameter. My question is, inside the ...
Shady's user avatar
  • 227
3 votes
1 answer
214 views

I have the following code to normalize std::filesystem::path to always use forward slashes as separators: static decltype(auto) fix_path_separator(const std::filesystem::path& path) { if ...
Dominik Kaszewski's user avatar

1
2 3 4 5
179