https://bugs.llvm.org/show_bug.cgi?id=47233
Bug ID: 47233
Summary: clang rejects valid c++ code
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected],
[email protected]
Please consider the following code, g++ compiles it successfully, while clang++
reports two errors:
$ cat s.C
#include <valarray>
#include <iostream>
using namespace std;
template<class Value>
class T
{
const long &dim;
public:
T(const double &_dim) : dim(_dim)
{}
};
int main(int argc, char *argv[])
{
long dim = 10;
T< valarray<double> > factory(dim);
}
$ clang++ -c s.C
s.C:10:31: error: reference member 'dim' binds to a temporary object whose
lifetime would be shorter than the lifetime of the constructed object
T(const double &_dim) : dim(_dim)
^~~~
s.C:8:15: note: reference member declared here
const long &dim;
^
s.C:10:31: error: reference member 'dim' binds to a temporary object whose
lifetime would be shorter than the lifetime of the constructed object
T(const double &_dim) : dim(_dim)
^~~~
s.C:16:25: note: in instantiation of member function 'T<std::valarray<double>
>::T' requested here
T< valarray<double> > factory(dim);
^
s.C:8:15: note: reference member declared here
const long &dim;
^
2 errors generated.
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs