This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

preprocessor/1565: nested expansion of macros broken in current cvs



>Number:         1565
>Category:       preprocessor
>Synopsis:       nested expansion of macros broken in current cvs
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jan 05 11:16:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Richard B. Kreckel
>Release:        gcc version 2.97 20010104 (experimental)
>Organization:
>Environment:
Debian GNU/Linux
>Description:
The code-snippet in the How-To-Repeat section should expand
CONCAT again give something like this after preprocessing:

int foo()
{
  return  bar  (  42  )  ;
}

Instead, it gives me this with the current CVS snapshot:

int foo()
{
  return CONCAT(KEEP,1) (LF, bar(42));
}

The (IMHO correct) output can be reproduced using 
gcc-2.7.2.1, gcc-2.95.2, Portland Group CC 3.1, Compaq C 
V6.1, Sun SC4.0, and SGI MIPSpro 7.30.

The code-snippet is a stripped down version of something
found in the CLN library.
>How-To-Repeat:
Just run the following snippet through gcc -E (or c++ -E):

// Concatenation of macroexpanded tokens.
// Example:
//   #undef x
//   #define y 16
//   CONCAT(x,y)        ==>  'x16' (not 'xy' !)
  #define CONCAT_(xxx,yyy)  xxx##yyy
  #define CONCAT(xxx,yyy)  CONCAT_(xxx,yyy)

#define GEN_F_OP2(arg,F_OP,r,result_assign)  \
  CONCAT(GEN_LF_OP2_AUX,r)(arg,F_OP,r,result_assign)

#define GEN_LF_OP2_AUX1(arg,F_OP,r,result_assign)  \
  result_assign CONCAT(KEEP,r) (LF, F_OP(arg));

#define KEEP0(EXPR0,EXPR1)  EXPR0
#define KEEP1(EXPR0,EXPR1)  EXPR1

int foo()
{
  GEN_F_OP2(42, bar, 1, return)
}

>Fix:
unknown
>Release-Note:
>Audit-Trail:
>Unformatted:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]