-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
[BUG][C] intToStr() macro is broken #20376
Comments
@imaami thanks for reporting the issue did you try the latest master? there's been a lot of fixes/enhancements recently made to the C client generator. |
I didn't specifically try it, I can see the problem is currently there and hasn't been touched in 6 years. Definition: openapi-generator/modules/openapi-generator/src/main/resources/C-libcurl/api-body.mustache Lines 8 to 12 in ff0fe26
Uses: openapi-generator/modules/openapi-generator/src/main/resources/C-libcurl/api-body.mustache Lines 142 to 145 in ff0fe26
openapi-generator/modules/openapi-generator/src/main/resources/C-libcurl/api-body.mustache Lines 155 to 158 in ff0fe26
openapi-generator/modules/openapi-generator/src/main/resources/C-libcurl/api-body.mustache Lines 168 to 171 in ff0fe26
openapi-generator/modules/openapi-generator/src/main/resources/C-libcurl/api-body.mustache Lines 181 to 184 in ff0fe26
|
It would be helpful to add |
thanks for the additional info. cc @zhemant (2018/11) @ityuhui (2019/12) @michelealbano (2020/03) also cc @eafer who contributed many PRs recently. |
@imaami FYI .Here is one recent improvement to the CMake file: https://github.com/OpenAPITools/openapi-generator/pull/20332/files#diff-ca9e359f588565d588ea904884e08c822102d784b18234aa07553cfd214bd2e2R9 |
The CFLAGS change in that commit enables two specific warnings and makes them build errors. Enabling warnings one at a time is tedious as there are dozens of useful ones. |
@wing328 Thank you for the cc, I was going to ask you to keep me in the loop for C changes. @imaami The reason I made those three warnings into build errors is because the automated testing only runs a build, and those particular warnings match a few regressions that have affected me lately. I agree that As for the bug you noticed: I don't think that macro should exist, |
To be clear, I think those added I've looked at the current state of the generated C code and you're right, it needs work. I'll try to do what I can, I could also use a good C generator for all the various LLM APIs out there. I'm cursed with being experienced in C and liking it a lot, but also being fascinated with the possibilities of AI. C and AI APIs are not a popular combination at all.
I'll do it now, won't take long. |
Of course heh, my point was that Also |
Hmm, shouldn't it be possible to enable the verbose makefile setting in cmake for automated testing? |
No idea, I had never used cmake before. |
Here's the commit. There's no regen of the sample code done, could someone who knows the codebase better take care of that? https://github.com/imaami/openapi-generator/tree/fix-c-int-to-string |
I think they need you to regenerate the samples so that the ci can check that everything still builds. It's not hard to do, assuming that you already built the codebase: https://github.com/OpenAPITools/openapi-generator/blob/master/.github/PULL_REQUEST_TEMPLATE.md |
Alright, thanks for the link. I think PR #20383 should be OK now. |
The generated C client code defines this macro:
This is broken because the destination array goes out of scope before it can be used. The generated code shows clearly that there is shadowing going on. This is what the result looks like after macro expansion:
I don't know how the generated code is able to work. Probably just a lucky case of compiler optimizations hiding the undefined behavior.
The text was updated successfully, but these errors were encountered: