This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/70820] New: GCC incorrectly accepts code that accesses nested names in an incomplete type
- From: "fdrocha at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 27 Apr 2016 13:52:20 +0000
- Subject: [Bug c++/70820] New: GCC incorrectly accepts code that accesses nested names in an incomplete type
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70820
Bug ID: 70820
Summary: GCC incorrectly accepts code that accesses nested
names in an incomplete type
Product: gcc
Version: 5.2.0
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: fdrocha at gmail dot com
Target Milestone: ---
Consider the following code
template<typename Derived>
struct Base {
static constexpr int i = Derived::j;
// static_assert(i>1, "First assert"); // First Assert
// int array[i]; // Array declation
};
struct Derived : public Base<Derived> {
static constexpr int j = 5 ;
};
static constexpr int k = Base<Derived>::i;
static_assert(Derived::i > 0, "Second Assert");
static_assert(Base<Derived>::i > 0, "Third Assert");
int array[Derived::i];
GCC compiles this (I tried all versions between 4.9.0 and 5.3.0) with no errors
or warnings even with -Wall -Wextra.
If you uncomment either the line marked "First Assert" or "Array Declaration"
it correctly gives the error "error: incomplete type 'Derived' used in nested
name specifier". It should also not accept the code without those lines, for
the same reason.