Bug 68530 - [C++14] sorry, unimplemented: unexpected AST of kind loop_expr
Summary: [C++14] sorry, unimplemented: unexpected AST of kind loop_expr
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 6.0
: P3 normal
Target Milestone: 6.0
Assignee: Jason Merrill
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks: constexpr
  Show dependency treegraph
 
Reported: 2015-11-25 04:52 UTC by lucdanton
Modified: 2016-05-23 09:37 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2015-11-25 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description lucdanton 2015-11-25 04:52:46 UTC
Possibly related to PR c++/68206, which could also be exhibiting both this and a potentially unrelated ICE.

$ g++-trunk --version
g++-trunk (GCC) 6.0.0 20151125 (experimental)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ cat main.cpp	
struct thing {
    void foo() {}
};

template<typename>
constexpr int count()
{
    auto item = thing {};
    for(; (item.foo(), false););
    return 0;
}

int main()
{
    static_assert( count<int>() == 0, "" );
}
$ g++-trunk -std=c++14 main.cpp
main.cpp: In function 'int main()':
main.cpp:15:5: error: non-constant condition for static assertion
     static_assert( count<int>() == 0, "" );
     ^~~~~~~~~~~~~

main.cpp:15:30: error: 'constexpr int count() [with <template-parameter-1-1> = int]' called in a constant expression
     static_assert( count<int>() == 0, "" );
                              ^

main.cpp:6:15: note: 'constexpr int count() [with <template-parameter-1-1> = int]' is not usable as a constexpr function because:
 constexpr int count()
               ^~~~~

main.cpp:6:15: sorry, unimplemented: unexpected AST of kind loop_expr
main.cpp:6: confused by earlier errors, bailing out
Comment 1 Jason Merrill 2016-04-19 18:50:26 UTC
Author: jason
Date: Tue Apr 19 18:49:54 2016
New Revision: 235217

URL: https://gcc.gnu.org/viewcvs?rev=235217&root=gcc&view=rev
Log:
	PR c++/68206 - Fix constexpr diagnostics with loops.

	PR c++/68530
	* constexpr.c (potential_constant_expression_1): Handle LOOP_EXPR
	and GOTO_EXPR.

Added:
    trunk/gcc/testsuite/g++.dg/cpp1y/constexpr-loop5.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/constexpr.c
Comment 2 Jason Merrill 2016-04-22 15:39:35 UTC
Author: jason
Date: Fri Apr 22 15:39:03 2016
New Revision: 235369

URL: https://gcc.gnu.org/viewcvs?rev=235369&root=gcc&view=rev
Log:
	PR c++/68206 - Fix constexpr diagnostics with loops.

	PR c++/68530
	* constexpr.c (potential_constant_expression_1): Handle LOOP_EXPR
	and GOTO_EXPR.

Added:
    branches/gcc-6-branch/gcc/testsuite/g++.dg/cpp1y/constexpr-loop5.C
Modified:
    branches/gcc-6-branch/gcc/cp/ChangeLog
    branches/gcc-6-branch/gcc/cp/constexpr.c
Comment 3 Paolo Carlini 2016-05-23 09:37:04 UTC
I think we can close this as fixed.