This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/59937] [constexpr] bogus diagnostic "used in its own initializer"
- From: "jota.uve at hotmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 14 Jan 2015 12:27:06 +0000
- Subject: [Bug c++/59937] [constexpr] bogus diagnostic "used in its own initializer"
- Auto-submitted: auto-generated
- References: <bug-59937-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59937
Javier V. GÃmez <jota.uve at hotmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jota.uve at hotmail dot com
--- Comment #2 from Javier V. GÃmez <jota.uve at hotmail dot com> ---
I found another case that worked in G++ 4.8.3 but fails in 4.9:
---------
main.cpp:
---------
int main ()
{
constexpr int n = 2;
A<n> a;
B b;
b.foo();
}
---------
a.hpp:
---------
template <size_t n> class A
{
static constexpr size_t getN() {return n;}
};
---------
b.hpp:
---------
class B
{
void foo ()
{
//has access to a A<n> object
constexpr int n = a.getN();
A<n> a2;
}
};
Compiler output:
B.hpp: error: the value of ânâ is not usable in a constant expression
A<n> a2;
^
B.hpp: note: ândimsâ used in its own initializer
constexpr int n = a.getN();
^