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++/67364] New: "accessing uninitialized member" error in constexpr context


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67364

            Bug ID: 67364
           Summary: "accessing uninitialized member" error in constexpr
                    context
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ldionne.2 at gmail dot com
  Target Milestone: ---

The following code triggers a compilation error on GCC trunk:

    template <typename Xn>
    struct element : Xn {
        constexpr element() : Xn() { }
    };

    template <typename Xn>
    struct closure {
        element<Xn> member;
        constexpr closure() { }
    };

    struct empty { };
    constexpr closure<empty> tup{};
    constexpr empty first = tup.member;


The error given is:

    [snip]: error: accessing uninitialized member 'closure<empty>::member'
     constexpr empty first = tup.member;
                                 ^

Note that writing the default constructor of `closure` as

    constexpr closure() : member{} { }

also triggers the failure. However, writing it as 

    constexpr closure() : member() { }

seems to do the trick.


Live example: http://melpon.org/wandbox/permlink/vPjfVOpuauYDkatT

Seems very similar to #65896.


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