[wave] Wave macro expansion problem
The code: // test_macros_o.cpp #define f(a) f(x + (a)) #define x 2 #define g f #define h g(~ int main() { #pragma wave trace(enable) h 5); #pragma wave trace(disable) return 0; } In the latest C++ standard at 16.3.5 paragraph 5 the expansion of 'h 5)' is given as: f(2 * (~5)) but the wave.exe driver gives: C:\Programming\VersionControl\boost\libs\vmd\test\test_macros_o.cpp:11:3: h C:\Programming\VersionControl\boost\libs\vmd\test\test_macros_o.cpp:4:9: see macro definition: h [ g(~ rescanning [ C:\Programming\VersionControl\boost\libs\vmd\test\test_macros_o.cpp:3:9: see macro definition: g [ f rescanning [ f ] ]
The code:
// test_macros_o.cpp
#define f(a) f(x + (a)) #define x 2 #define g f #define h g(~
int main() {
#pragma wave trace(enable)
h 5);
#pragma wave trace(disable)
return 0; }
In the latest C++ standard at 16.3.5 paragraph 5 the expansion of 'h 5)' is given as:
f(2 * (~5))
but the wave.exe driver gives:
C:\Programming\VersionControl\boost\libs\vmd\test\test_macros_o.cpp:11:3: h
C:\Programming\VersionControl\boost\libs\vmd\test\test_macros_o.cpp:4:9: see macro definition: h [ g(~ rescanning [
C:\Programming\VersionControl\boost\libs\vmd\test\test_macros_o.cpp:3:9: see macro definition: g [ f rescanning [ f ] ]
It actually should say something like: t.cpp:13:4: error: improperly terminated macro invocation or replacement- list terminates in partial macro expansion (not supported yet): missing ')' This is a known bug in wave caused by its recursive expansion algorithm which does not allow to handle this pathologic corner case. All I could do was to detect and report this. Regards Hartmut --------------- http://boost-spirit.com http://stellar.cct.lsu.edu
On 9/10/2013 7:13 AM, Hartmut Kaiser wrote:
The code:
// test_macros_o.cpp
#define f(a) f(x + (a)) #define x 2 #define g f #define h g(~
int main() {
#pragma wave trace(enable)
h 5);
#pragma wave trace(disable)
return 0; }
In the latest C++ standard at 16.3.5 paragraph 5 the expansion of 'h 5)' is given as:
f(2 * (~5))
but the wave.exe driver gives:
C:\Programming\VersionControl\boost\libs\vmd\test\test_macros_o.cpp:11:3: h
C:\Programming\VersionControl\boost\libs\vmd\test\test_macros_o.cpp:4:9: see macro definition: h [ g(~ rescanning [
C:\Programming\VersionControl\boost\libs\vmd\test\test_macros_o.cpp:3:9: see macro definition: g [ f rescanning [ f ] ]
It actually should say something like:
t.cpp:13:4: error: improperly terminated macro invocation or replacement- list terminates in partial macro expansion (not supported yet): missing ')'
You are correct. It does say this on stderr. Sorry for the noise.
This is a known bug in wave caused by its recursive expansion algorithm which does not allow to handle this pathologic corner case. All I could do was to detect and report this.
It might be worth it to fix this known bug.
participants (2)
-
Edward Diener
-
Hartmut Kaiser