According to the C++23 standard, what is the output of this program?
#include <iostream>
int main(int argc, char* argv[]) {
std::cout << (argv[argc] == nullptr);
}There is no bug in this program, the programmer is supposed to be able to do this.
1
You might think we access an out-of-bounds array element and the program behaviour is undefined, but §[basic.start.main]¶2 explicitly states:
The value of
argv[argc]shall be 0.