#include <iostream>
struct A {
int x;
};
void foo(A a) {
std::cout << a.x << std::endl;
}
int main() {
A a;
foo(a);
foo(A());
}
Is it possible to pass a value of r type Ato foo()without initializing the value? Do I need to use either value initialization or lvalue?
What is the point of avoiding the initialization of value when it "costs" no more than ten nanoseconds, you can ask. How about a situation like this: we are hunting for an error in an outdated application caused by uninitialized memory access with valgrind, and zero is NOT considered a valid value for the application. Initializing a value will prevent valgrind from locating uninitialized memory access.
, - UB, "" . .