Today I found out that Arduino IDE supports designated initializer syntax, which was introduced as a part of C++20 (and C99, but that's a different story).
Does it mean g++ in Arduino IDE 1.x was updated to C++20 standard?
I mean code like this:
struct Foo {
int a,
int b
};
Foo bar = {.a = 5, .b = 7};
That would be nice, however, I suspect that the compiler simply allows it and issues a warning you may not see. When I compile something similar I see the following.
warning: ISO C++ does not allow C99 designated initializers [-Wpedantic]
My understanding is that a compiler version which does not support designated initializers wouldn't simply throw a warning, it would rather report an error due to use of unknown syntax. Am I wrong?
Which core do you use? Mine is MiniCore, and I get no warnings. Also I tried cores for ESP32 (required additional definition of LED_BUILTIN, but worked), ESP8266 (complained about void function not being explicitly terminated by return statement, but worked) and STM32F103C8T6 (worked without any warnings).
The compiler itself probably supports C++20 and beyond, however, it is instructed to adhere to the C++11 standard, including some GNU extensions, by the compiler options given by the Arduino toolchain (-std=gnu++11).
At the same time, the compiler is instructed to be lenient when it comes to using constructs that are not supported by the selected standard and those that are "wrong" but admissible for other reasons (-fpermissive). Furthermore, warnings are suppressed by default, so many of these admissible violations go unnoticed.
If you want to be informed about these violations, you could enable the -Wall, -Wextra and -pedantic compiler options, perhaps in combination with the -std=c++11 option to make sure no GNU extensions are used.
I looked at the compiler options for the AVR core by the way, it could be that other cores use different options.