Bug 59641 - ICE with invalid expression in vector arithmetic
Summary: ICE with invalid expression in vector arithmetic
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.9.0
: P3 normal
Target Milestone: 4.9.0
Assignee: Not yet assigned to anyone
URL:
Keywords: error-recovery, ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2013-12-30 20:30 UTC by Volker Reichelt
Modified: 2014-01-02 22:48 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.8.0, 4.9.0
Last reconfirmed: 2013-12-30 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2013-12-30 20:30:16 UTC
The following invalid code snippet (compiled with "-std=c++11")
triggers an ICE since GCC 4.8.0:

======================================================
typedef int T __attribute__((vector_size(8)));

T foo(const T& a, const T& b)
{
  constexpr T c = a < b;
  return c ? a : b;
}
======================================================

bug.cc: In function 'T foo(const T&, const T&)':
bug.cc:5:23: error: 'a' is not a constant expression
   constexpr T c = a < b;
                       ^
bug.cc:6:18: internal compiler error: tree check: expected vector_type, have error_mark in build_conditional_expr_1, at cp/call.c:4495
   return c ? a : b;
                  ^
0xd8f084 tree_check_failed(tree_node const*, char const*, int, char const*, ...)
        ../../gcc/gcc/tree.c:9192
0x58441c tree_check
        ../../gcc/gcc/tree.h:2707
0x58441c build_conditional_expr_1
        ../../gcc/gcc/cp/call.c:4495
0x5844bc build_conditional_expr(unsigned int, tree_node*, tree_node*, tree_node*, int)
        ../../gcc/gcc/cp/call.c:4931
0x6a8e53 build_x_conditional_expr(unsigned int, tree_node*, tree_node*, tree_node*, int)
        ../../gcc/gcc/cp/typeck.c:6017
0x682b2c cp_parser_question_colon_clause
        ../../gcc/gcc/cp/parser.c:8080
0x682b2c cp_parser_assignment_expression
        ../../gcc/gcc/cp/parser.c:8116
0x6847b4 cp_parser_expression
        ../../gcc/gcc/cp/parser.c:8274
0x67af3a cp_parser_expression
        ../../gcc/gcc/cp/parser.c:8313
0x67af3a cp_parser_jump_statement
        ../../gcc/gcc/cp/parser.c:10677
0x67af3a cp_parser_statement
        ../../gcc/gcc/cp/parser.c:9370
0x67b5c9 cp_parser_statement_seq_opt
        ../../gcc/gcc/cp/parser.c:9740
0x67b73e cp_parser_compound_statement
        ../../gcc/gcc/cp/parser.c:9694
0x68f15b cp_parser_function_body
        ../../gcc/gcc/cp/parser.c:18610
0x68f15b cp_parser_ctor_initializer_opt_and_function_body
        ../../gcc/gcc/cp/parser.c:18646
0x6934fe cp_parser_function_definition_after_declarator
        ../../gcc/gcc/cp/parser.c:22678
0x694394 cp_parser_function_definition_from_specifiers_and_declarator
        ../../gcc/gcc/cp/parser.c:22590
0x694394 cp_parser_init_declarator
        ../../gcc/gcc/cp/parser.c:16588
0x69562f cp_parser_simple_declaration
        ../../gcc/gcc/cp/parser.c:11200
0x679003 cp_parser_block_declaration
        ../../gcc/gcc/cp/parser.c:11081
Please submit a full bug report, [etc.]


Marc, vector arithmetic looks like your domain, would you mind having a look?
Comment 1 Marc Glisse 2013-12-30 22:25:41 UTC
In build_conditional_expr_1, we check error_operand_p (arg1) on the original arguments, but we don't check it again after force_rvalue, which we probably should do.
Comment 2 Marc Glisse 2014-01-02 22:43:26 UTC
Author: glisse
Date: Thu Jan  2 22:43:24 2014
New Revision: 206303

URL: http://gcc.gnu.org/viewcvs?rev=206303&root=gcc&view=rev
Log:
2014-01-02  Marc Glisse  <marc.glisse@inria.fr>

	PR c++/59641
gcc/cp/
	* call.c (build_conditional_expr_1): Check the return value of
	force_rvalue.
gcc/testsuite/
	* g++.dg/cpp0x/pr59641.C: New file.


Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/pr59641.C   (with props)
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/call.c
    trunk/gcc/testsuite/ChangeLog

Propchange: trunk/gcc/testsuite/g++.dg/cpp0x/pr59641.C
            ('svn:eol-style' added)

Propchange: trunk/gcc/testsuite/g++.dg/cpp0x/pr59641.C
            ('svn:keywords' added)
Comment 3 Marc Glisse 2014-01-02 22:48:28 UTC
Fixed on trunk, not worth backporting.