Closed ludocode closed 2 years ago
Thank you for reporting the issue. It's indeed a bug and violation of C17 specification. To fix that, I have changed macro argument substitution procedure to avoid argument expansions in #
and ##
operators. Previously macro arguments were expanded prior to replacement list processing, now expansion happens at the point of argument substitution in replacement list. Added examples from issue description to the test suite.
Regarding bug reporting, issues can be opened on this repo. I have just created basic mailing list and bug tracker on sourcehut, which can be used as well.
The preprocessor stringification operator
#
and token pasting operator##
should inhibit macro expansion of the arguments to which they apply. Only the tokens resulting from the##
operator should be expanded.Example:
The macro
foo
must not be expanded. Compiling this withgcc -E
,clang -E
,tcc -E
,chibicc -E
, MSVCcl /EP
, etc. all yield:With
kefir -p
(from commit 8952442c1794719057e8ad2b55b810004fbb0f9b) I get the following output:If I reverse the arguments to cat, e.g.
cat(_,foo)
, I get this error instead:Another example:
With all other compilers this preprocesses to:
Preprocessing with
kefir -p
yields:See section 6.10.3.1.1 and sections 6.10.3.3.2-3 in the C17 spec. Macro parameters are substituted and expanded except when they are after
#
or##
or before##
. Any argument after # is substituted and stringified, not expanded. Any argument before or after##
is substituted, the adjacent tokens are concatenated, and then the resulting tokens are expanded.Is this the correct place to report bugs? It looks like the project is also on sourcehut. I couldn't find any issue tracker or mailing list there or any other way to report bugs.