www.digitalmars.com         C & C++   DMDScript  

D.gnu - ICE when calling templated function from extern (C++) templated

reply Elronnd <elronnd em.slashem.me> writes:
Here's a minimal example:

   void r(T...)(T args) {}

   extern (C++) {
           void s(T...)(T args) { r(args); }
   }

   void main() {
           s(0);
   }

Traceback from GDC:

   cc1d: ../../gcc-6.3.0/gcc/d/dfrontend/cppmangle.c:185: void 
CppMangleVisitor::source_name(Dsymbol*, bool): Assertion `t' 
failed.
   minim.d: In function ‘D main’:
   minim.d:9:2: internal compiler error: Aborted
     s(0);
     ^
   0xb91c3f crash_signal
         ../../gcc-6.3.0/gcc/toplev.c:333
   0x5f4f26 CppMangleVisitor::source_name(Dsymbol*, bool)
         ../../gcc-6.3.0/gcc/d/dfrontend/cppmangle.c:185
   0x5f0b82 CppMangleVisitor::mangle_function(FuncDeclaration*)
         ../../gcc-6.3.0/gcc/d/dfrontend/cppmangle.c:462
   0x5f0b82 CppMangleVisitor::mangleOf(Dsymbol*)
         ../../gcc-6.3.0/gcc/d/dfrontend/cppmangle.c:575
   0x5f0b82 toCppMangle(Dsymbol*)
         ../../gcc-6.3.0/gcc/d/dfrontend/cppmangle.c:910
   0x67ba17 Mangler::visit(Declaration*)
         ../../gcc-6.3.0/gcc/d/dfrontend/mangle.c:421
   0x67a2f8 mangleExact(FuncDeclaration*)
         ../../gcc-6.3.0/gcc/d/dfrontend/mangle.c:877
   0x6ed183 get_symbol_decl(Declaration*)
         ../../gcc-6.3.0/gcc/d/d-decls.cc:164
   0x72ab78 ExprVisitor::visit(VarExp*)
         ../../gcc-6.3.0/gcc/d/expr.cc:2062
   0x7298ef build_expr(Expression*, bool)
         ../../gcc-6.3.0/gcc/d/expr.cc:2851
   0x72b759 ExprVisitor::visit(CallExp*)
         ../../gcc-6.3.0/gcc/d/expr.cc:1633
   0x7298ef build_expr(Expression*, bool)
         ../../gcc-6.3.0/gcc/d/expr.cc:2851
   0x729a5f build_expr_dtor(Expression*)
         ../../gcc-6.3.0/gcc/d/expr.cc:2895
   0x731d7c IRVisitor::visit(ExpStatement*)
         ../../gcc-6.3.0/gcc/d/toir.cc:649
   0x731bf8 IRVisitor::visit(CompoundStatement*)
         ../../gcc-6.3.0/gcc/d/toir.cc:665
   0x731b95 build_ir(FuncDeclaration*)
         ../../gcc-6.3.0/gcc/d/toir.cc:1037
   0x706d84 FuncDeclaration::toObjFile()
         ../../gcc-6.3.0/gcc/d/d-objfile.cc:1359
   0x7083a4 Module::genobjfile(bool)
         ../../gcc-6.3.0/gcc/d/d-objfile.cc:1465
   0x6e7f22 d_parse_file()
         ../../gcc-6.3.0/gcc/d/d-lang.cc:1215
   Please submit a full bug report,
   with preprocessed source if appropriate.
   Please include the complete backtrace with any bug report.
   See <http://gcc.gnu.org/bugs.html> for instructions.
Dec 27 2016
parent reply "Iain Buclaw via D.gnu" <d.gnu puremagic.com> writes:
On 28 December 2016 at 07:51, Elronnd via D.gnu <d.gnu puremagic.com> wrote:
 Here's a minimal example:

   void r(T...)(T args) {}

   extern (C++) {
           void s(T...)(T args) { r(args); }
   }

   void main() {
           s(0);
   }
It seems the bug is also in dmd too? Unless it is fixed in master/latest release, in which case will need to find out when this happened.
Dec 31 2016
parent reply Elronnd <elronnd em.slashem.me> writes:
On Saturday, 31 December 2016 at 15:10:36 UTC, Iain Buclaw wrote:
 On 28 December 2016 at 07:51, Elronnd via D.gnu 
 <d.gnu puremagic.com> wrote:
 *snip*
 It seems the bug is also in dmd too?  Unless it is fixed in 
 master/latest release, in which case will need to find out when 
 this happened.
It works fine for me on dmd.
Jan 08 2017
next sibling parent "Iain Buclaw via D.gnu" <d.gnu puremagic.com> writes:
On 8 January 2017 at 09:08, Elronnd via D.gnu <d.gnu puremagic.com> wrote:
 On Saturday, 31 December 2016 at 15:10:36 UTC, Iain Buclaw wrote:
 On 28 December 2016 at 07:51, Elronnd via D.gnu <d.gnu puremagic.com>
 wrote:
 *snip*
 It seems the bug is also in dmd too?  Unless it is fixed in master/latest
 release, in which case will need to find out when this happened.
It works fine for me on dmd.
Then the version of dmd I have probably isn't new enough then. If the latest is fine, then the C++ mangler just needs to be sync'd between the two codebases. It's totally encapsulated, so is relatively straightforward, once you get over the D -> C++ conversion. ;-)
Jan 08 2017
prev sibling next sibling parent "Iain Buclaw via D.gnu" <d.gnu puremagic.com> writes:
On 8 January 2017 at 11:06, Iain Buclaw <ibuclaw gdcproject.org> wrote:
 On 8 January 2017 at 09:08, Elronnd via D.gnu <d.gnu puremagic.com> wrote:
 On Saturday, 31 December 2016 at 15:10:36 UTC, Iain Buclaw wrote:
 On 28 December 2016 at 07:51, Elronnd via D.gnu <d.gnu puremagic.com>
 wrote:
 *snip*
 It seems the bug is also in dmd too?  Unless it is fixed in master/latest
 release, in which case will need to find out when this happened.
It works fine for me on dmd.
Then the version of dmd I have probably isn't new enough then. If the latest is fine, then the C++ mangler just needs to be sync'd between the two codebases. It's totally encapsulated, so is relatively straightforward, once you get over the D -> C++ conversion. ;-)
Looks like this is the related bug in DMD: https://issues.dlang.org/show_bug.cgi?id=15372
Jan 08 2017
prev sibling next sibling parent "Iain Buclaw via D.gnu" <d.gnu puremagic.com> writes:
On 8 January 2017 at 16:42, Iain Buclaw <ibuclaw gdcproject.org> wrote:
 On 8 January 2017 at 11:06, Iain Buclaw <ibuclaw gdcproject.org> wrote:
 On 8 January 2017 at 09:08, Elronnd via D.gnu <d.gnu puremagic.com> wrote:
 On Saturday, 31 December 2016 at 15:10:36 UTC, Iain Buclaw wrote:
 On 28 December 2016 at 07:51, Elronnd via D.gnu <d.gnu puremagic.com>
 wrote:
 *snip*
 It seems the bug is also in dmd too?  Unless it is fixed in master/latest
 release, in which case will need to find out when this happened.
It works fine for me on dmd.
Then the version of dmd I have probably isn't new enough then. If the latest is fine, then the C++ mangler just needs to be sync'd between the two codebases. It's totally encapsulated, so is relatively straightforward, once you get over the D -> C++ conversion. ;-)
Looks like this is the related bug in DMD: https://issues.dlang.org/show_bug.cgi?id=15372
Actually, no. It's this bug that is related indirectly, as the C++ mangler sees a Tuple parameter '[int]', but with the patch applied, it flattens all tuples so we are just left with the Type 'int'. https://issues.dlang.org/show_bug.cgi?id=7469
Jan 08 2017
prev sibling parent "Iain Buclaw via D.gnu" <d.gnu puremagic.com> writes:
On 8 January 2017 at 18:23, Iain Buclaw <ibuclaw gdcproject.org> wrote:
 On 8 January 2017 at 16:42, Iain Buclaw <ibuclaw gdcproject.org> wrote:
 On 8 January 2017 at 11:06, Iain Buclaw <ibuclaw gdcproject.org> wrote:
 On 8 January 2017 at 09:08, Elronnd via D.gnu <d.gnu puremagic.com> wrote:
 On Saturday, 31 December 2016 at 15:10:36 UTC, Iain Buclaw wrote:
 On 28 December 2016 at 07:51, Elronnd via D.gnu <d.gnu puremagic.com>
 wrote:
 *snip*
 It seems the bug is also in dmd too?  Unless it is fixed in master/latest
 release, in which case will need to find out when this happened.
It works fine for me on dmd.
Then the version of dmd I have probably isn't new enough then. If the latest is fine, then the C++ mangler just needs to be sync'd between the two codebases. It's totally encapsulated, so is relatively straightforward, once you get over the D -> C++ conversion. ;-)
Looks like this is the related bug in DMD: https://issues.dlang.org/show_bug.cgi?id=15372
Actually, no. It's this bug that is related indirectly, as the C++ mangler sees a Tuple parameter '[int]', but with the patch applied, it flattens all tuples so we are just left with the Type 'int'. https://issues.dlang.org/show_bug.cgi?id=7469
But of course there's a bug in the patch! https://issues.dlang.org/show_bug.cgi?id=15789
Jan 08 2017