This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/70820] New: GCC incorrectly accepts code that accesses nested names in an incomplete type


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]