You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Interesting. It looks like the version of gcc you use pre-processes the concatenation token ## in a different way than prior versions (I'm talking of the version of GCC and not of C++ standard).
Namely, considering this macro definition (where the error is seen most of the time):
#define __DBG_0_ARG__() __dbg__ /* DBG(): access to debug object */
#define __DBG_1_ARG__(X) /* DBG(N) {..}: debug operator, prints debug indention */\
if( __dbg__(X) ) \
TLOCK(__dbg__.mutex()) \
if( __dbg__(X, __func__) ) // now print the prompt
#define __DBG_2_ARG__(O, X) /* DBG(F, N) {..}: using debug operator from F */\
if( O.__dbg__(X) ) \
TLOCK(O.__dbg__.mutex()) \
if( O.__dbg__(X, __func__) ) // now print the prompt
#define __DBG_4TH_ARG__(arg1, arg2, arg3, arg4, ...) arg4
#define __DBG_CHOOSER__(ARGS...) \
__DBG_4TH_ARG__(dummy, ##ARGS, __DBG_2_ARG__, __DBG_1_ARG__, __DBG_0_ARG__)
#define DBG(ARGS...) __DBG_CHOOSER__(ARGS)(ARGS)
the line : 454 | template<class X> Debug(X &x) { x.DBG().severity(x); };
must result in resolving DBG() into the token __DBG_0_ARG__, while the error indicates that it resolved into the token __DBG_1_ARG__ instead.
This means, that the argument substitution in the line __DBG_4TH_ARG__(dummy, ##ARGS, __DBG_2_ARG__, __DBG_1_ARG__, __DBG_0_ARG__)
resulted in 5 arguments, whereas it's expected to be expanded into 4 arguments (given token ## and the empty argument ARGS).
It could be a change in the macro behavior in the newer c++ compilers or a peculiar behavior of this gcc version. I'd need to take more time to experiment with different compiler versions, and perhaps rewrite some macros, given c++20 introduced new __VA_OPT__ macro to handle similar expansions I do in DBG macro.
OS:
Distributor ID: Ubuntu
Description: Ubuntu 20.04.4 LTS
Release: 20.04
Codename: focal
Arch:
x86_64
g++ (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
Compile command: g++ -o jtc -Wall -std=c++17 -Ofast jtc.cpp
Compiler output see attached file
jtc.err.gz
The text was updated successfully, but these errors were encountered: