Bug 96140 - internal compiler error: in expand_intrinsic_vaarg
Summary: internal compiler error: in expand_intrinsic_vaarg
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: d (show other bugs)
Version: 10.1.0
: P3 normal
Target Milestone: ---
Assignee: Iain Buclaw
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-07-09 20:22 UTC by Iain Buclaw
Modified: 2020-08-01 19:03 UTC (History)
0 users

See Also:
Host: x86_86-linux-gnu
Target: x86_86-linux-gnu
Build: x86_86-linux-gnu
Known to work:
Known to fail: 10.1.0, 9.3.0
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Iain Buclaw 2020-07-09 20:22:58 UTC
void test_va_arg(ref int a, ...) { return va_arg!int(_argptr, a); }
---
0x6231bc expand_intrinsic_vaarg
	../../gcc/d/intrinsics.cc:514
0x6231bc maybe_expand_intrinsic(tree_node*)
	../../gcc/d/intrinsics.cc:845
0x7a1381 d_build_call(TypeFunction*, tree_node*, tree_node*, Array<Expression*>*)
	../../gcc/d/d-codegen.cc:1947
0x7b3153 ExprVisitor::visit(CallExp*)
	../../gcc/d/expr.cc:1843
0x7b131a build_expr(Expression*, bool)
	../../gcc/d/expr.cc:3085
0x7b13c1 build_expr_dtor(Expression*)
	../../gcc/d/expr.cc:3108
0x7bd411 IRVisitor::visit(ExpStatement*)
	../../gcc/d/toir.cc:1040
0x7bd11c IRVisitor::build_stmt(Statement*)
	../../gcc/d/toir.cc:273
0x7bd11c IRVisitor::visit(CompoundStatement*)
	../../gcc/d/toir.cc:1057
0x7bd11c IRVisitor::visit(CompoundStatement*)
	../../gcc/d/toir.cc:1047
0x7bd11c IRVisitor::build_stmt(Statement*)
	../../gcc/d/toir.cc:273
0x7bd11c IRVisitor::visit(CompoundStatement*)
	../../gcc/d/toir.cc:1057
0x7bd11c IRVisitor::visit(CompoundStatement*)
	../../gcc/d/toir.cc:1047
0x7bcfed IRVisitor::build_stmt(Statement*)
	../../gcc/d/toir.cc:273
0x7bcfed build_function_body(FuncDeclaration*)
	../../gcc/d/toir.cc:1469
0x7b08bf DeclVisitor::visit(FuncDeclaration*)
	../../gcc/d/decl.cc:1006
0x7ad36f build_decl_tree(Dsymbol*)
	../../gcc/d/decl.cc:1047
0x7bad80 build_module_tree(Module*)
	../../gcc/d/modules.cc:728
0x7afa5b DeclVisitor::visit(Module*)
	../../gcc/d/decl.cc:147
0x7ad36f build_decl_tree(Dsymbol*)
	../../gcc/d/decl.cc:1047
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Comment 1 Iain Buclaw 2020-07-09 20:28:30 UTC
Similarly va_start can't handle ref parameters either.

void test_va_start(ref va_list a, ...) { return va_start(a, a); }
---
0x623234 expand_intrinsic_vastart
	../../gcc/d/intrinsics.cc:549
0x623234 maybe_expand_intrinsic(tree_node*)
	../../gcc/d/intrinsics.cc:848
0x7a1381 d_build_call(TypeFunction*, tree_node*, tree_node*, Array<Expression*>*)
	../../gcc/d/d-codegen.cc:1947
0x7b3153 ExprVisitor::visit(CallExp*)
	../../gcc/d/expr.cc:1843
0x7b131a build_expr(Expression*, bool)
	../../gcc/d/expr.cc:3085
0x7b13c1 build_expr_dtor(Expression*)
	../../gcc/d/expr.cc:3108
0x7bd411 IRVisitor::visit(ExpStatement*)
	../../gcc/d/toir.cc:1040
0x7bd11c IRVisitor::build_stmt(Statement*)
	../../gcc/d/toir.cc:273
0x7bd11c IRVisitor::visit(CompoundStatement*)
	../../gcc/d/toir.cc:1057
0x7bd11c IRVisitor::visit(CompoundStatement*)
	../../gcc/d/toir.cc:1047
0x7bd11c IRVisitor::build_stmt(Statement*)
	../../gcc/d/toir.cc:273
0x7bd11c IRVisitor::visit(CompoundStatement*)
	../../gcc/d/toir.cc:1057
0x7bd11c IRVisitor::visit(CompoundStatement*)
	../../gcc/d/toir.cc:1047
0x7bcfed IRVisitor::build_stmt(Statement*)
	../../gcc/d/toir.cc:273
0x7bcfed build_function_body(FuncDeclaration*)
	../../gcc/d/toir.cc:1469
0x7b08bf DeclVisitor::visit(FuncDeclaration*)
	../../gcc/d/decl.cc:1006
0x7ad36f build_decl_tree(Dsymbol*)
	../../gcc/d/decl.cc:1047
0x7bad80 build_module_tree(Module*)
	../../gcc/d/modules.cc:728
0x7afa5b DeclVisitor::visit(Module*)
	../../gcc/d/decl.cc:147
0x7ad36f build_decl_tree(Dsymbol*)
	../../gcc/d/decl.cc:1047
Comment 2 CVS Commits 2020-07-30 21:45:21 UTC
The master branch has been updated by Iain Buclaw <ibuclaw@gcc.gnu.org>:

https://gcc.gnu.org/g:dfc420f8d4492dbf5f45df4fecf93cb9645c0d7b

commit r11-2441-gdfc420f8d4492dbf5f45df4fecf93cb9645c0d7b
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Thu Jul 16 18:34:18 2020 +0200

    d: Fix ICE in expand_intrinsic_vaarg
    
    Both intrinsics did not handle the case where the va_list object comes
    from a ref parameter.
    
    gcc/d/ChangeLog:
    
            PR d/96140
            * intrinsics.cc (expand_intrinsic_vaarg): Handle ref parameters as
            arguments to va_arg().
            (expand_intrinsic_vastart): Handle ref parameters as arguments to
            va_start().
    
    gcc/testsuite/ChangeLog:
    
            PR d/96140
            * gdc.dg/pr96140.d: New test.
Comment 3 CVS Commits 2020-08-01 17:23:18 UTC
The releases/gcc-10 branch has been updated by Iain Buclaw <ibuclaw@gcc.gnu.org>:

https://gcc.gnu.org/g:891bd1f15280def813bf6a363495d44951e13e04

commit r10-8558-g891bd1f15280def813bf6a363495d44951e13e04
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Thu Jul 16 18:34:18 2020 +0200

    d: Fix ICE in expand_intrinsic_vaarg
    
    Both intrinsics did not handle the case where the va_list object comes
    from a ref parameter.
    
    gcc/d/ChangeLog:
    
            PR d/96140
            * intrinsics.cc (expand_intrinsic_vaarg): Handle ref parameters as
            arguments to va_arg().
            (expand_intrinsic_vastart): Handle ref parameters as arguments to
            va_start().
    
    gcc/testsuite/ChangeLog:
    
            PR d/96140
            * gdc.dg/pr96140.d: New test.
    
    (cherry picked from commit dfc420f8d4492dbf5f45df4fecf93cb9645c0d7b)
Comment 4 CVS Commits 2020-08-01 17:23:52 UTC
The releases/gcc-9 branch has been updated by Iain Buclaw <ibuclaw@gcc.gnu.org>:

https://gcc.gnu.org/g:a6e2dc45099d5d23dfeae245617f316e95ac646b

commit r9-8776-ga6e2dc45099d5d23dfeae245617f316e95ac646b
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Thu Jul 16 18:34:18 2020 +0200

    d: Fix ICE in expand_intrinsic_vaarg
    
    Both intrinsics did not handle the case where the va_list object comes
    from a ref parameter.
    
    gcc/d/ChangeLog:
    
            PR d/96140
            * intrinsics.cc (expand_intrinsic_vaarg): Handle ref parameters as
            arguments to va_arg().
            (expand_intrinsic_vastart): Handle ref parameters as arguments to
            va_start().
    
    gcc/testsuite/ChangeLog:
    
            PR d/96140
            * gdc.dg/pr96140.d: New test.
    
    (cherry picked from commit dfc420f8d4492dbf5f45df4fecf93cb9645c0d7b)
Comment 5 Iain Buclaw 2020-08-01 19:03:52 UTC
Fixed.