Bug 82022 - constexpr lambda in template context: expression ‘<lambda>’ is not a constant expression
Summary: constexpr lambda in template context: expression ‘<lambda>’ is not a constant...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 7.0.1
: P3 normal
Target Milestone: 8.0
Assignee: Not yet assigned to anyone
URL:
Keywords: c++-lambda
Depends on:
Blocks: lambdas
  Show dependency treegraph
 
Reported: 2017-08-29 15:16 UTC by bastien penavayre
Modified: 2022-03-11 00:32 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2017-10-05 00:00:00


Attachments
source code (141 bytes, text/plain)
2017-08-29 15:16 UTC, bastien penavayre
Details
log error (1.36 KB, text/plain)
2017-08-29 15:16 UTC, bastien penavayre
Details

Note You need to log in before you can comment on or make changes to this bug.
Description bastien penavayre 2017-08-29 15:16:06 UTC
Created attachment 42073 [details]
source code

in a template context a constexpr lambda doesn't seem to be able to be constexpr evaluated and its result is not constexpr.

if constexpr ([]() constexpr {return true;}()); //expression ‘<lambda>’ is not a constant expression

constexpr bool r = []() constexpr {return true;}();
if constexpr (r); //"r" used in its own initializer
Comment 1 bastien penavayre 2017-08-29 15:16:44 UTC
Created attachment 42074 [details]
log error
Comment 2 paolo@gcc.gnu.org 2018-03-05 10:19:42 UTC
Author: paolo
Date: Mon Mar  5 10:19:11 2018
New Revision: 258241

URL: https://gcc.gnu.org/viewcvs?rev=258241&root=gcc&view=rev
Log:
2018-03-05  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/82022
	* g++.dg/cpp1z/constexpr-lambda20.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/cpp1z/constexpr-lambda20.C
Modified:
    trunk/gcc/testsuite/ChangeLog
Comment 3 Paolo Carlini 2018-03-05 10:22:17 UTC
Fixed in trunk. Of course this requires -std=c++17