compilation error in "clang & libstdc++-12.1 & c++20"
alex-700 opened this issue · 1 comments
alex-700 commented
Hello, fbthrift
team!
- The code generated for metadata.thrift is not compiling in "
clang-14 & libstdc++-12.1 & c++20
" environment. The version of clang isn't important, but version oflibstdc++
andcxx_standard
are. - The problem can be seen in the snippet. The
copy-ctor
ofvector<ThriftConstValuePair>
insideset_cvmap
can't be instantiated before definition ofThriftConstValuePair
. And a compiler, IMHO, can make a decision to instantiate it eagerly in instantiation point at the end ofThriftConstValue
definition. So, IIYC, the generated code is "ill-formed no diagnostic required". - I don't see a simple solution, but can suggest several hard ones:
- Member methods in such "cyclic" cases (or even always) can be declared inside the class, but defined later after definition of all classes.
- All classes can be put into some
struct X
(like last-level namespace), which will enforce standard-compliant compilers postpone instantiation to the end of X definition.