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

"[C++] Incorrect Namespace Resolution for Root Table in Generated VerifyBuffer Code" #8442

Open
ChristophKarlHeck opened this issue Nov 26, 2024 · 0 comments

Comments

@ChristophKarlHeck
Copy link

ChristophKarlHeck commented Nov 26, 2024

Hi,
I got the following error when I used flatbuffers version 24.3.25 in C++.
Here are the steps to reproduce:

  1. 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;
  1. FlatBuffers Compiler: I compiled this schema using the following command:
flatc --cpp serial_mail.fbs
  1. 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]       |    
  1. 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

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

1 participant