sql-parser
sql-parser copied to clipboard
Fix the `'dynamic_cast' not permitted with '-fno-rtti'` error when integrated with LLVM/MLIR.
A compile error occurs when including the "SQLParser.h"
in another project. (sql_parser as third-party)
/thirdparty/sql-parser/src/sql/CreateStatement.h:74:67: error: 'dynamic_cast' not permitted with '-fno-rtti'
74 | ynamic_cast<ColumnDefinition*>(tableElem)) {
| ^
/thirdparty/sql-parser/src/sql/CreateStatement.h:76:82: error: 'dynamic_cast' not permitted with '-fno-rtti'
76 | dynamic_cast<TableConstraint*>(tableElem)) {
| ^
Separate the declaration and definition of the setColumnDefsAndConstraints
should fix this.
Any chance to can provide an example of how to trigger this issue?
Which clang version do you use?
The definition of setColumnDefsAndConstraints
is in header file, and it tires to call dynamic_cast.
LLVM/MLIR project implicitly add -fno-rtti
flag (this flag disable dynamic_cast
) and this will cause a compilation error as shown in the title.
Add -fno-rtti
in example/Makefile will be an MRE.
#example/Makefile
CFLAGS = -std=c++1z -lstdc++ -Wall -fno-rtti -Werror -I../src/ -L../
all:
$(CXX) $(CFLAGS) example.cpp -o example -lsqlparser
Hi @Bouncner, any chance to get this landed? This fix does not introduce any changes but only removes the function definition from the header file.
In the long run, we would like to remove the cluttered
statements.cpp
. For that, could you please move the function to a newCreateStatement.cpp
?
Hi @Bouncner, the above issue has been addressed, PTAL.
Feel free to merge.