Skip to main content
edited body
Source Link
M.M
  • 141.3k
  • 25
  • 220
  • 387

I think gcc is correct. Although C11 6.10.3/12 describes the invocation of COMB as having two arguments (ADD and 1,2), once COMB has been expanded the resulting token sequence is ADD ( 1 +, 2 ), and 6.10.3.4/1 is clear that the result of the first replacement is rescanned as a preprocessing token sequence. An argument from a previous step that consisted of multiple tokens is not somehow glued into a single token for rescanning.

6.10.3.4/1:

After all parameters in the replacement list have been substituted and # and ## processing has taken place, all placemarker preprocessing tokens are removed. The resulting preprocessing token sequence is then rescanned, along with all subsequent preprocessing tokens of the source file, for more macro names to replace

I think gcc is correct. Although C11 6.10.3/12 describes the invocation of COMB as having two arguments (ADD and 1,2), once COMB has been expanded the resulting token sequence is ADD ( 1 + 2 ), and 6.10.3.4/1 is clear that the result of the first replacement is rescanned as a preprocessing token sequence. An argument from a previous step that consisted of multiple tokens is not somehow glued into a single token for rescanning.

6.10.3.4/1:

After all parameters in the replacement list have been substituted and # and ## processing has taken place, all placemarker preprocessing tokens are removed. The resulting preprocessing token sequence is then rescanned, along with all subsequent preprocessing tokens of the source file, for more macro names to replace

I think gcc is correct. Although C11 6.10.3/12 describes the invocation of COMB as having two arguments (ADD and 1,2), once COMB has been expanded the resulting token sequence is ADD ( 1 , 2 ), and 6.10.3.4/1 is clear that the result of the first replacement is rescanned as a preprocessing token sequence. An argument from a previous step that consisted of multiple tokens is not somehow glued into a single token for rescanning.

6.10.3.4/1:

After all parameters in the replacement list have been substituted and # and ## processing has taken place, all placemarker preprocessing tokens are removed. The resulting preprocessing token sequence is then rescanned, along with all subsequent preprocessing tokens of the source file, for more macro names to replace

Source Link
M.M
  • 141.3k
  • 25
  • 220
  • 387

I think gcc is correct. Although C11 6.10.3/12 describes the invocation of COMB as having two arguments (ADD and 1,2), once COMB has been expanded the resulting token sequence is ADD ( 1 + 2 ), and 6.10.3.4/1 is clear that the result of the first replacement is rescanned as a preprocessing token sequence. An argument from a previous step that consisted of multiple tokens is not somehow glued into a single token for rescanning.

6.10.3.4/1:

After all parameters in the replacement list have been substituted and # and ## processing has taken place, all placemarker preprocessing tokens are removed. The resulting preprocessing token sequence is then rescanned, along with all subsequent preprocessing tokens of the source file, for more macro names to replace