On Thu, Jan 26, 2023 at 09:45:35AM -0500, Patrick Palka via Gcc-patches wrote: > > -extern const unsigned char tree_code_length[]; > > + > > +#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH, > > +#define END_OF_BASE_TREE_CODES 0, > > +constexpr unsigned char tree_code_length[] = { > > +#include "all-tree.def" > > +}; > > + > > +#undef DEFTREECODE > > +#undef END_OF_BASE_TREE_CODES > > IIUC defining these globals as non-inline constexpr gives them internal > linkage, and so each TU contains its own unique copy of these globals. > This bloats cc1plus by a tiny bit and is technically an ODR violation > because some inline functions such as tree_class_check also ODR-use > these variables and so each defn of tree_class_check will refer to a > "different" tree_code_class. Since inline variables are a C++17 > feature, I guess we could fix this by defining the globals the old way > before C++17 and as inline constexpr otherwise?
Agreed, just use __cpp_inline_variables >= 201606L to select between the old and new ways. Jakub