0

What is the name for the structure below: (j,0)?
Why does this (tuple?) thing evaluate to 0.0f?
Why is it legal C++17 to assign (j,0) to a float?

"00_j0-why.cpp"

#include <iostream>
using std::cout, std::endl, std::flush, std::ostream;

int main(){
    unsigned long int j = 4;
    float k = (j,0);
    cout << "    j = " << j     << endl;
    cout << "(j,0) = " << (j,0) << endl;
    cout << "    k = " << k     << endl;
}

Compile command: g++ 00_j0-why.cpp -std=gnu++17
Result:

    j = 4
(j,0) = 0
    k = 0

I have included a complete working example of what seems to me should be a compiler error. It should have not compiled. This is an example of the problem I have been tracking for hours and I am absolutely livid that this is legal code. I do not even have a name for what (j,0) is.

0 Answers0