flatc generates invalid C++ code with `--grpc-callback-api`
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Start by running the grpctest project with flatc --grpc-callback-api and inspect the generated tests/monster_test.grpc.fb.h around the StubInterface and CallbackService declarations. Correct the declaration scope, then verify that the generated code compiles successfully and the grpctest project passes.
Written by the indexing model from the issue text.
Description
When the --grpc-callback-api option is used, flatc generates invalid C++ code that fails to compile.
The grpctest test project fails with the following error:
2>W:\Dev\flatbuffers\tests\monster_test.grpc.fb.h(361,23): error C2039: 'CallbackService': is not a member of 'MyGame::Example::MonsterStorage'
2>(compiling source file '../../Dev/flatbuffers/tests/monster_test.grpc.fb.cc')
2> W:\Dev\flatbuffers\tests\monster_test.grpc.fb.h(33,7):
2> see declaration of 'MyGame::Example::MonsterStorage'
After inspecting the generated monster_test.grpc.fb.h file, it appears that the declaration of CallbackService is emitted in the wrong scope.
The generated code effectively declares:
MyGame::Example::MonsterStorage::StubInterface::CallbackService
while it should be declared as:
MyGame::Example::MonsterStorage::CallbackService
I verified this behavior both on the current master branch and on commit deb3d934 (the commit that originally introduced this functionality). The problem is reproducible in both cases.
From what I can see, the fix appears to be trivial: the generated class CallbackService; line simply needs to be swapped with the following line containing the closing brace, so that CallbackService is declared in the scope of MonsterStorage rather than inside StubInterface.
Expected behavior
flatc --grpc-callback-api should generate valid C++ code, and the grpctest project should compile successfully.
Actual behavior
Generated code places CallbackService in the wrong scope, causing compilation errors.
- Dominant language
- C++
- Stars
- 26.5k
- Forks
- 3.7k
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from google/flatbuffers
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
google/flatbuffers#9191 · 2 reactions ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
google/flatbuffers#9189 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 84/100
google/flatbuffers#9162 · 1 reaction ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
google/flatbuffers#9111 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
google/flatbuffers#9069 ·
All issues in google/flatbuffers
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
AXERA-TECH/ax-llm#77 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
bug-unconfirmed
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
NVIDIA/cuda-samples#453 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
infiniflow/infinity#3502 ·