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

Refrain from using nested designators #253

Closed
kubalaguna opened this issue Feb 11, 2025 · 5 comments
Closed

Refrain from using nested designators #253

kubalaguna opened this issue Feb 11, 2025 · 5 comments

Comments

@kubalaguna
Copy link
Contributor

kubalaguna commented Feb 11, 2025

Hello,

Using this format (nested designator):

 es_event_authentication_t auth = {
      .data.token = &token
}

instead of:

 es_event_authentication_t auth = {
      .data = {.token = &token}
}

causes some compatibility issues on our end.

Would it be possible to add a check to disallow nested designators? If not, could you please try to use the latter format instead?

Example: #252

@russellhancox
Copy link
Member

Can you elaborate on what compatibility issues you're having?
Designated initializers are a C99 feature

@kubalaguna
Copy link
Contributor Author

Build fails with

error: nested designators are a C99 extension [-Werror,-Wc99-designator]

@pmarkowsky
Copy link
Contributor

@kubalaguna is your goal for this issue to prevent this from happening in the future?

We'd need some sort of static analysis framework to add a presubmit check for this pattern. Unfortunately many of the easy ones like semgrep, or codeql don't support Objective-C/C++.

Meta's infer does but admittedly I've not used it.

@kubalaguna
Copy link
Contributor Author

Yes, if we could prevent it with a presubmit, it would be great. But if it's not easy to do, please just consider not using this pattern.

@pmarkowsky
Copy link
Contributor

I'm going to close the issue as this is complicated for many reasons and look at trying not to use the pattern in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants