flatbuffers
flatbuffers copied to clipboard
[C++] Incorrect Namespace Resolution for Root Table in Generated VerifyBuffer Code
Hi, I got the following error when I used flatbuffers version 24.3.25 in C++. Here are the steps to reproduce:
- FlatBuffers Schema: Here is the schema (serial_mail.fbs) that reproduces the issue:
namespace SerialMail;
// Define a struct for the 3-byte array
struct Value {
data_0: uint8;
data_1: uint8;
data_2: uint8;
}
// Main table
table SerialMail {
inputs: [Value]; // Vector of raw data
classification: [float]; // List of classifications
classification_active: bool;
channel: bool;
}
root_type SerialMail;
- FlatBuffers Compiler: I compiled this schema using the following command:
flatc --cpp serial_mail.fbs
- Generated Code: In the generated header (serial_mail_generated.h), the following line of code was produced:
return verifier.VerifyBuffer<SerialMail::SerialMail>(nullptr);
This leads to a compilation error:
[build] /libs/flatbuffers/include/flatbuffers/verifier.h:245:29: note: template argument deduction/substitution failed:
[build] /include/serializing_data/serial_mail_generated.h:151:55: error: type/value mismatch at argument 1 in template parameter list for 'template<class T> bool flatbuffers::VerifierTemplate<TrackVerifierBufferSize>::VerifyBuffer(const char*) [with bool TrackVerifierBufferSize = false]'
[build] 151 | return verifier.VerifyBuffer<SerialMail::SerialMail>(nullptr);
[build] |
- I had to manually adjust the VerifyBuffer as follows:
return verifier.VerifyBuffer<SerialMail>(nullptr);
The issue seems to be related to how the namespace and root table are resolved in the generated code. If this is not a bug, I would appreciate guidance on whether the schema or build process needs adjustment.
Cheers, Christoph