GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix rescanning when a macro expansion result forms a new function-like macro call by pfultz2 · Pull Request #682 · cppcheck-opensource/simplecpp

Conversation

@pfultz2

@pfultz2 pfultz2 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

When the result of a macro expansion ends with the name of a function-like
macro and the tokens that follow supply its arguments, simplecpp performed
that rescan only once instead of repeatedly. Given:

#define a(b, c) c
#define d() a
#define g(e) h(e, ) h(e, )
#define h(e, b) d()(, e)()
#define i()
g(i)

g(i) expanded to i ( ) i ( ) instead of nothing: inside h's body
d()(, e)(), d() was correctly rescanned as a(, i) yielding i, but the
resulting i was never rescanned against the trailing ().

The rescan logic was also missing logic to prevent re-expanding the same macro name: so #define f() f + f()() gave f instead of f().

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Your Name added 4 commits July 13, 2026 10:42
Your Name
Fix test case with recursive scans
0fa51dc
Your Name
Avoid a recursive expansion
96fc564
Your Name
Remove the while(true) loop
fd4f092
Your Name
Declare variable const
388b0ad
@pfultz2

pfultz2 commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

@danmar @firewave Any feedback?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pfultz2

pfultz2 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

@danmar Are you able to review?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

danmar
danmar approved these changes Jul 24, 2026
View reviewed changes
@danmar

danmar commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

I hope this might fix some existing issue i.e. #549

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pfultz2

pfultz2 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

@danmar Can this be merged now?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@danmar
danmar merged commit 74a5a63 into cppcheck-opensource:master Aug 4, 2026
26 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@danmar

danmar commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

This did not solve #549 unfortunately :-(

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pfultz2
pfultz2 deleted the macro-expansion branch August 4, 2026 20:07
@pfultz2

pfultz2 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

This did not solve #549 unfortunately :-(

I opened #695 which fixes that issue.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@danmar danmar mentioned this pull request Aug 29, 2026
Fix: simplecpp ## fails to expand function-like macro when '(' is not adjacent #655
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@danmar danmar danmar approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@pfultz2 @danmar
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.