Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace-dependent-typedef breaks on typedef in template struct #279

Open
emaxx-google opened this issue Jan 14, 2025 · 4 comments · May be fixed by #281
Open

replace-dependent-typedef breaks on typedef in template struct #279

emaxx-google opened this issue Jan 14, 2025 · 4 comments · May be fixed by #281
Assignees
Labels

Comments

@emaxx-google
Copy link

The following error is generated:

pass_clang::replace-dependent-typedef has encountered a bug:
pass failed to modify the variant

when the input is:

template <typename T>
struct A {
  struct Inner;
  typedef A::Inner Bar;
};
@emaxx-google
Copy link
Author

It seems that the problem is this check that gets misled by different string representations: A<T>::Inner vs. A::Inner:

if (Str == TdefTyStr)

@emaxx-google
Copy link
Author

emaxx-google commented Jan 14, 2025

Some possible directions:

  • A: Do string comparison of the original text and the replacement - and exit with an error if it's the same.
    • => very simple to implement, but feels a bit wasteful (2 applications of the pass in the same location might be required before the idempotence gets discovered).
  • B: Skip applying the pass to typedefs that don't actually refer, directly or indirectly, to another typedef.
    • => this corresponds better to the idea behind the pass (the word "dependent" in the pass' name), but might be a bit more fragile to implement.
  • ...?

@eeide
Copy link
Member

eeide commented Jan 14, 2025

Thank you for your bug report!

@emaxx-google
Copy link
Author

I'm happy to propose a PR as a starting point. (And probably basic unit tests for this pass.)

emaxx-google added a commit to emaxx-google/creduce that referenced this issue Jan 14, 2025
Only consider typedefs that depend on other typedefs in
replace-dependent-typedef.

This prevents the pass from reporting a success when no actual
change has been made, like in the case when a typedef belongs to
and refers to a template struct (where multiple possible string
representations may confuse the checks).

This fixes csmith-project#279.
emaxx-google added a commit to emaxx-google/creduce that referenced this issue Jan 14, 2025
Only consider typedefs that depend on other typedefs in
replace-dependent-typedef.

This prevents the pass from reporting a success when no actual
change has been made, like in the case when a typedef belongs to
and refers to a template struct (where multiple possible string
representations may confuse the checks).

This fixes csmith-project#279.
emaxx-google added a commit to emaxx-google/creduce that referenced this issue Jan 14, 2025
Only consider typedefs that depend on other typedefs in
replace-dependent-typedef.

This prevents the pass from reporting a success when no actual
change has been made, like in the case when a typedef belongs to
and refers to a template struct (where multiple possible string
representations may confuse the checks).

This fixes csmith-project#279.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants