Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Ian_Mallett1
Beginner
95 Views

Regression: Incorrect Recursive Handling of ##__VA_ARGS__ After Passing Non-Argument in 16.0 Update 2

Hi,

Code that compiled in 16.0 Update 1 no longer compiles after upgrading to Update 2. Here is a simple test case:

#define RECURS(ARG0,...)\
	recurs(ARG0,##__VA_ARGS__)
#define FUNCS_OKAY(ARG0,...)\
	direct(ARG0,    ##__VA_ARGS__)\
	RECURS(ARG0,    ##__VA_ARGS__)
#define FUNCS_BROKEN(ARG0,...)\
	direct(ARG0, 7, ##__VA_ARGS__)\
	RECURS(ARG0, 7, ##__VA_ARGS__)

FUNCS_OKAY("arg0");
FUNCS_OKAY("arg0","args");

FUNCS_BROKEN("arg0");
FUNCS_BROKEN("arg0","args");

Intel 16.0 Update 2 produces (preprocess only, use "-EP -P"):

direct("arg0" ) recurs("arg0" );
direct("arg0","args") recurs("arg0","args");

direct("arg0", 7 ) recurs("arg0",7,);
direct("arg0", 7,"args") recurs("arg0",7,"args");

Notice that the comma was (erroneously) not elided after the "7" in the broken case (line 4). However, e.g. GCC 5.3.0 produces (use "-E"):

direct("arg0") recurs("arg0");
direct("arg0","args") recurs("arg0","args");

direct("arg0", 7) recurs("arg0", 7);
direct("arg0", 7,"args") recurs("arg0", 7,"args");

Thanks,
Ian

0 Kudos
4 Replies
Judith_W_Intel
Employee
95 Views

 

Are you seeing this problem on Windows or Linux? We did make a fix related to this that had a regression in Update 2 -- but I think it only affected Microsoft mode compatibility.

I can't reproduce it with our current 16.0 compiler on Linux.

sptxl15-219> cat t.c

#define RECURS(ARG0,...)\
    recurs(ARG0,##__VA_ARGS__)

#define FUNCS_OKAY(ARG0,...)\
    direct(ARG0,    ##__VA_ARGS__)\
    RECURS(ARG0,    ##__VA_ARGS__)

#define FUNCS_BROKEN(ARG0,...)\
    direct(ARG0, 7, ##__VA_ARGS__)\
    RECURS(ARG0, 7, ##__VA_ARGS__)

FUNCS_OKAY("arg0");
FUNCS_OKAY("arg0","args");

FUNCS_BROKEN("arg0");
FUNCS_BROKEN("arg0","args");

sptxl15-220> icc -EP -P t.c
sptxl15-221> cat t.I

 


direct("arg0") recurs("arg0");
direct("arg0","args") recurs("arg0","args");

direct("arg0", 7) recurs("arg0",7);
direct("arg0", 7,"args") recurs("arg0",7,"args");

sptxl15-222> icc -V
Intel(R) C Compiler for applications running on IA-32, Version 16.0 Beta Build x
Built Apr  8 2016 12:34:05 by jward4 on sptxl15 in /home/nsl/jward4/d/workspaces/16_0cfe/dev
Copyright (C) 1985-2016 Intel Corporation.  All rights reserved.

sptxl15-223>

thanks

Judy

Ian_Mallett1
Beginner
95 Views

That is correct; the test system is Windows 7.

Judith_W_Intel
Employee
95 Views

 

ok that makes sense.

Right before update 2 was released we made this fix (that caused the regression you are seeing):

Microsoft compatibility: comma preceding empty __VA_ARGS__ in macro argument

When __VA_ARGS__ is preceded in a macro definition by a comma and the
variadic argument is empty, the Microsoft preprocessor generally omits the
comma from the expanded text, as does the front end in --microsoft mode;
see the entry of 2/15/07.  However, the Microsoft preprocessor does not
suppress the comma if it appears in a macro argument, while the front end
did so in all contexts.  This is now fixed.  For example, with --microsoft:

  #define MAC(...) __VA_ARGS__
  #define MF(x, ...) fun(x, __VA_ARGS__,<-)
  #define MM(x, ...) MAC(x, __VA_ARGS__,<-)
  MF(->);   // Expands to "fun(->,<-)" (first comma suppressed)
  MM(->);   // Now expands to "->,,<-" (first comma not suppressed)

This regression introduced by the fix above has since been fixed (our internal tracking number for the regression was DPD200407512) and your code will be preprocessed as expected in update 3.

Sorry for the inconvenience!!!

Judy

Kittur_G_Intel
Employee
95 Views

Thanks Judy for the update, as always. I'll monitor and let Ian know as soon as Update 3 is released anytime soon.

Ian, appreciate your patience through this and I'll keep you updated on the release.

Regards,
Kittur

Reply