Questions tagged [language-lawyer]
For questions about the intricacies of formal or authoritative specifications of programming languages.
language-lawyer
8,407
questions
-1
votes
1
answer
38
views
Difference between {} as an object and {} as empty block scope in JS [duplicate]
let a=10;
{} //empty block scope
//lets say there is an object
let b ={};
so, how does js differentiate between the two ?
console.log({}=={}) ( as an example )
is there a way where we can use {} as ...
0
votes
1
answer
39
views
In C language, do multiple implicit conversions that occur in an expression have a certain order?
(My question might be quite long. I would be very grateful if you could read it through.)
I am learning C language by reading the C11 standard. I find that there are quite a lot of implicit ...
3
votes
1
answer
110
views
std::variant::operator< unexpected call to implicit bool conversion. Varies between standards
I'm seeing some unexpected behavior when using the std::variant::operator<. In the situation where the type has an implicit bool conversion operator and its less operator is not a member function (...
2
votes
0
answers
41
views
Is the initialization of an object a modification to a memory location when considering conflict actions?
struct A{int a; A():a(1){}}
std::atomic<A*> x;
// thread 1:
A* ptr = new A(); // #1
x.store(ptr,memory_order::relaxed);
//thread 2:
auto ptr = x.load(memory_order::relaxed);
int b = ptr-&...
1
vote
1
answer
85
views
consteval member function allowed?
I have this c++20/23 code:
#include <cstddef>
template <size_t N>
class Foo {
public:
consteval size_t size() noexcept { return N; }
size_t real_size() {
...
2
votes
1
answer
72
views
Order of c++ template arguments affecting compilation
I just encountered a new compilation error in my code after a visual studio update. I have stripped my code down to what I think is a minimal example. I have two templated functions both called pow - ...
6
votes
2
answers
155
views
In C++26, are implementations required to "initialize" uninitialized variables to some fixed byte pattern?
In C++26, reading uninitialized variables is no longer undefined, it's "erroneous" now (What is erroneous behavior? How is it different from undefined behavior?).
However, the wording for ...
1
vote
1
answer
18
views
UML Association, ownership of the Association itself?
This is actually two questions rolled into one:
(1) Association inherits Relationship. For classes which inherit DirectedRelationship, the convention seems to be that the specialized ...
2
votes
1
answer
63
views
Is `AcqRel` necessary in the atomic read-modify-write operation to avoid data race in a lock-free multi-producer single consumer queue?
Consider this snippet code of implementing a lock-free multi-producer single-consumer queue in Rust
struct Node<T> {
next: AtomicPtr<Node<T>>,
value: Option<T>,
}
impl&...
2
votes
1
answer
26
views
UML Actor, UseCase and BehavioredClassifiers
Both UML Actor and UseCase specialize BehavioredClassifier which implies that they can own Behaviors. It is clear to me that UseCase needs to have Behaviors in order to link itself to StateMachine or ...
3
votes
2
answers
85
views
Interpreting the format specifier in printf("%.-1f", 34.14)
Consider the following invocation of printf():
printf("%.-1f", 34.14);
it specifies a negative precision value of -1. Making this call with glibc, we get:
%0.-1f
is this correct? If so, ...
4
votes
2
answers
111
views
Move elision in explicit object member functions
If one calls explicit object member function of a temporary, must the move of the temporary be elided in the explicit object parameter?
Consider the following example, where struct A has move ...
-1
votes
1
answer
49
views
tool do determine the value category an expression: understanding the result when using references
Looking into definition of value-categories, I tried a snippet proposed here: https://stackoverflow.com/a/16638081/21691539
template <typename T>
struct value_category {
// Or can be an ...
3
votes
2
answers
29
views
UML Association: Are "navigableOwnedEnd" and "ownedEnd" the same?
Please refer to the following diagram which is shown in the UML 2.5.1 specification at section 11.5.2 on page 241 of the PDF file:
What is the difference here? navigableOwnedEnd subsets ownedEnd, and ...
4
votes
1
answer
84
views
Can I use template parameters to refer to base class member functions?
I'm trying to understand why this code doesn't compile with GCC but compiles with MSVC:
template<class TParams>
class Selector : public TParams::DataSource1, public TParams::DataSource2
{
...