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

Cannot use D struct/class in QList #116

Open
ThomasBrixLarsen opened this issue Oct 15, 2019 · 3 comments
Open

Cannot use D struct/class in QList #116

ThomasBrixLarsen opened this issue Oct 15, 2019 · 3 comments

Comments

@ThomasBrixLarsen
Copy link

pragma(cppmap, "<QtCore/QList>");
import(C++) Qt, *;

struct Test {}

void main()
{
    QList!Test tests;
}
binary    /usr/bin/ldc2
version   1.18.0-git-26fadd1-dirty (DMD v2.088.0, LLVM 9.0.0)
config    /etc/ldc2.conf (x86_64-pc-linux-gnu)
calypso   driver args: clang -std=c++11 -D_REENTRANT -fPIE -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/include/qt/mkspecs/linux-g++ -I/usr/include/qt -I/usr/include/qt/QtWidgets -I/usr/include/qt/QtGui -I/usr/include/qt/QtCore -I/usr/include/qt/QtCore/5.13.1 -I/usr/include/qt/QtCore/5.13.1/QtCore -c -x c++-header .calypso_cache/calypso_cache.h 
predefs   LDC all D_Version2 assert D_ModuleInfo D_Exceptions D_TypeInfo X86_64 D_InlineAsm_X86_64 D_HardFloat LittleEndian D_LP64 D_PIC linux Posix CRuntime_Glibc CppRuntime_Gcc LDC_LLVM_900 CppStdLib_libstdcxx
parse     qlist
importall qlist
import    object        (/usr/include/dlang/ldc/object.d)
import    core.internal.array.appending (/usr/include/dlang/ldc/core/internal/array/appending.d)
import    core.internal.array.comparison        (/usr/include/dlang/ldc/core/internal/array/comparison.d)
import    core.internal.array.equality  (/usr/include/dlang/ldc/core/internal/array/equality.d)
import    core.internal.array.casting   (/usr/include/dlang/ldc/core/internal/array/casting.d)
import    core.internal.array.concatenation     (/usr/include/dlang/ldc/core/internal/array/concatenation.d)
import    core.internal.array.construction      (/usr/include/dlang/ldc/core/internal/array/construction.d)
import    core.internal.array.capacity  (/usr/include/dlang/ldc/core/internal/array/capacity.d)
import    core.internal.hash    (/usr/include/dlang/ldc/core/internal/hash.d)
import    core.internal.traits  (/usr/include/dlang/ldc/core/internal/traits.d)
import    core.internal.convert (/usr/include/dlang/ldc/core/internal/convert.d)
import    cpp.core      (/usr/include/dlang/ldc/cpp/core.d)
semantic  qlist
entry     main          qlist.d
semantic2 qlist
semantic3 qlist

Program received signal SIGSEGV, Segmentation fault.
0x000055555723e2c0 in clang::ASTContext::getRecordType(clang::RecordDecl const*) const ()
(gdb) bt
#0  0x000055555723e2c0 in clang::ASTContext::getRecordType(clang::RecordDecl const*) const ()
#1  0x000055555621237a in cpp::DeclMapper::toType(Loc, Type*, Scope*, unsigned long) ()
#2  0x000055555620dd24 in ?? ()
#3  0x000055555620d58d in ?? ()
#4  0x000055555620fe5e in cpp::TemplateDeclaration::getClangInst(Scope*, Array<RootObject*>*) ()
#5  0x0000555556210075 in cpp::TemplateDeclaration::matchWithInstance(Scope*, TemplateInstance*, Array<RootObject*>*, Array<Expression*>*, int) ()
#6  0x0000555555f71f06 in _D3dmd9dtemplate16TemplateInstance13findBestMatchMFPSQBz6dscope5ScopePSQCr4root5array__T5ArrayTCQDq10expression10ExpressionZQBkZb ()
#7  0x0000555555f6f811 in _D3dmd10dsymbolsem24templateInstanceSemanticFCQBs9dtemplate16TemplateInstancePSQCz6dscope5ScopePSQDr4root5array__T5ArrayTCQEq10expression10ExpressionZQBkZv ()
#8  0x0000555555f34cd7 in _D3dmd7typesem7resolveFCQw5mtype4TypeKxSQBm7globals3LocPSQCd6dscope5ScopePCQCv10expression10ExpressionPQDcPCQEc7dsymbol7DsymbolbZv ()
#9  0x0000555556008103 in _D3dmd7typesem12typeSemanticRCQBc5mtype4TypeSQBr7globals3LocPSQCi6dscope5ScopeZ13visitInstanceMFCQDrQCp12TypeInstanceZQDl ()
#10 0x0000555555f35053 in typeSemantic(Type*, Loc, Scope*) ()
#11 0x0000555556040a8a in DsymbolSemanticVisitor::visit(VarDeclaration*) ()
#12 0x0000555555f9122b in ExpressionSemanticVisitor::visit(DeclarationExp*) ()
#13 0x0000555555fdca07 in StatementSemanticVisitor::visit(ExpStatement*) ()
#14 0x0000555555fdcf4a in StatementSemanticVisitor::visit(CompoundStatement*) ()
#15 0x0000555555f2e03e in Semantic3Visitor::visit(FuncDeclaration*) ()
#16 0x0000555555f32241 in Semantic3Visitor::visit(Module*) ()
#17 0x00005555560a38d5 in mars_mainBody(Param&, Array<char const*>&, Array<char const*>&) ()
#18 0x00005555561c696d in cppmain() ()
#19 0x000055555784ba20 in _D2rt6dmain212_d_run_main2UAAamPUQgZiZ6runAllMFZv ()
#20 0x000055555784b82f in _d_run_main2 ()
#21 0x000055555784b68e in _d_run_main ()
#22 0x0000555555ed4ed5 in main ()
#23 0x00007ffff2c1b153 in __libc_start_main () from /usr/lib/libc.so.6
#24 0x0000555555ed6e8e in _start ()
@Syniurge
Copy link
Owner

Unless this is really blocking, this won't be high priority, making Clang aware of D structs and classes may not be easy at all to implement and I wasn't planning to experiment on it until later.

Not being able to use D classes/structs with Qt templates makes connect() unusable so moc.d had to work around it with connect2().
Can you work around it too without too much hassle or do you have a use case that strongly requires this feature?

@ThomasBrixLarsen
Copy link
Author

It's not blocking. I'm porting some existing C++ code to D. So I can change the QList uses to D arrays instead. And use QList with C++ structs/classes until I'm able to port them.

I saw a project to have dmd generate C++ headers. Could it make it easier? At least for extern(C++)?

@ThomasBrixLarsen
Copy link
Author

This is not strictly related to the template issue: I've ported a few thousand lines, and so far the most infuriating annoyance, is that stack trace. It always happens in cpp::DeclMapper::toType->clang::ASTContext::getRecordType. I would really like an error instead with a line number.

Syniurge added a commit that referenced this issue Nov 6, 2019
… D structs/classes/enums), error with source locations instead of segfaulting/triggering asserts.

While waiting for possible experimentations for complete resolution (?) of #116, this will be a bit less crude.
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

2 participants