I declare a struct in a header file. I use this struct in two compilation units. One is compiled with -std=c++11 and the other with -std=c++20. The sizeof my struct is different in the two compilation units.
Is it allowed to mix any -std=c++20 and -std=c++11 code or am I using gcc the wrong way ?
These answers do not tell if it's expected to work.
I'm not using two different version of « the same » compiler (Can you mix c++ compiled with different versions of the same compiler).
I'm not mixing two incompatible versions of the standard in my code, as far as I know (Mixing different C++ standards with GCC).
I'm not using libraries, including standard libraries (except for displaying the results, but that's not where the problem lies) (Is it safe to link C++17, C++14, and C++11 objects).
I'm using gcc (Debian 10.2.1-6) 10.2.1 20210110 on Debian 11. I wonder if this version of gcc has a bug.
Code demonstrating the problem :
I declare a struct in a header file. I use this struct in two compilation units. One is compiled with -std=c++11 and the other with -std=c++20. The sizeof my struct is different in the two compilation units. Is it allowed to mix any -std=c++20 and -std=c++11 code or am I using gcc the wrong way ? These answers do not tell if it's expected to work. [list] [*]I'm not using two different version of « the same » compiler (Can you mix c++ compiled with different versions of the same compiler). [*]I'm not mixing two incompatible versions of the standard in my code, as far as I know (Mixing different C++ standards with GCC). [*]I'm not using libraries, including standard libraries (except for displaying the results, but that's not where the problem lies) (Is it safe to link C++17, C++14, and C++11 objects). [/list] I'm using gcc (Debian 10.2.1-6) 10.2.1 20210110 on Debian 11. I wonder if this version of gcc has a bug. Code demonstrating the problem : [code]$ cat 1.h #ifndef DEF1 #define DEF1