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

Superfluous parentheses in declarations are handled incorrectly #606

Closed
DivineWinds opened this issue Jan 25, 2024 · 4 comments
Closed

Superfluous parentheses in declarations are handled incorrectly #606

DivineWinds opened this issue Jan 25, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@DivineWinds
Copy link

Input:

void (*p);

Output:

void (*) p;

This is wrong and fails to compile. Ideally the unnecessary parentheses would be removed but leaving them untouched is also an option.

@andreasfertig
Copy link
Owner

Hello @DivineWinds,

thanks for spotting this! A fix is on its way.

Andreas

@andreasfertig andreasfertig added the bug Something isn't working label Feb 13, 2024
andreasfertig added a commit that referenced this issue Feb 13, 2024
Fixed #606: Correct handling of parentheses in a variable declaration.
@DivineWinds
Copy link
Author

DivineWinds commented Feb 13, 2024

Thanks for the fix @andreasfertig. I'm sorry for being a nuisance but unfortunately I discovered a problem with it. void (**p); and deeper multilevel pointers still exhibit the old behaviour. Also, using cv-qualifiers breaks even the one level pointer case, that is, void (*volatile p); becomes void (*pvolatile); (I'm only using volatile to skip the initalizer. const does the same thing). Combining the two results in the old behaviour as well: void (**volatile p); becomes void (**volatile) p;.

EDIT: I don't know if this is useful in any way but turning any of the above examples into array declarations seems to fix them, e.g. void (**volatile p[2]); remains unchanged. There are however pathological array declarations like void (*(*p)[3]); -> void (*p(*)[3]);. The last thing I noticed is that adding typedef to any of the examples, including the last one makes them behave correctly.

@andreasfertig
Copy link
Owner

Hello @DivineWinds,

thanks for the testing. What is the use-case for all that? Is this production code?

Andreas

@DivineWinds
Copy link
Author

DivineWinds commented Feb 13, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants