[llvm-bugs] [Bug 37450] New: clang falsely(?) accepts c++17 code in c++14 mode?
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon May 14 06:43:35 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=37450
Bug ID: 37450
Summary: clang falsely(?) accepts c++17 code in c++14 mode?
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Frontend
Assignee: unassignedclangbugs at nondot.org
Reporter: lebedev.ri at gmail.com
CC: llvm-bugs at lists.llvm.org
This is creduce output, and it's not really easy to follow i'm afraid :/
https://godbolt.org/g/VMF1Ww
template <template <typename> class a> struct c {
template <typename> struct B { typedef a<int> d; };
};
template <template <typename> class e> struct f { typedef c<e> b; };
template <template <typename> class e> struct g { typedef f<e> d; };
template <class h> struct i {
static int j() {
typedef typename h::template B<int>::d k;
new k;
return 0;
}
};
template <typename l> struct m {
int j() {
(void)i<typename l::b>::j;
return 0;
}
};
template <typename> struct n {
static constexpr auto o = [] {};
};
bool p = &m<g<n>::d>::j;
Clang trunk accepts this without any warning with -Wall -Wextra -Werror
-std=c++14
gcc 8.1, with the same options, fails with
<source>: In instantiation of 'constexpr const n<int>::<lambda()> n<int>::o':
<source>:20:25: required from 'struct n<int>'
<source>:9:5: required from 'static int i<h>::j() [with h = c<n>]'
<source>:15:5: required from 'int m<l>::j() [with l = f<n>]'
<source>:22:23: required from here
<source>:20:25: error: the type 'const n<int>::<lambda()>' of 'constexpr'
variable 'n<int>::o' is not literal
static constexpr auto o = [] {};
^
<source>:20:25: note: 'n<int>::<lambda()>' is not literal because:
cc1plus: note: 'n<int>::<lambda()>' is a closure type, which is only literal
in C++17 and later
<source>:20:25: error: in-class initialization of static data member 'const
n<int>::<lambda()> n<int>::o' of non-literal type
Compiler returned: 1
Is this clang's or gcc's bug?
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180514/559abf5d/attachment.html>
More information about the llvm-bugs
mailing list