public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/65312] New: Implicitly-declared default constructor must be defined as deleted
@ 2015-03-04 12:10 radventure at yandex dot ru
  2015-03-04 12:16 ` [Bug c++/65312] " redi at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: radventure at yandex dot ru @ 2015-03-04 12:10 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 65312
           Summary: Implicitly-declared default constructor must be
                    defined as deleted
           Product: gcc
           Version: 4.9.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: radventure at yandex dot ru

I think the next code should not be successfully compiled because of
implicitly-declared default constructor of Array struct should be deleted

#include <cstdint>
#include <iostream>

constexpr uint64_t Fib(uint32_t i)
{
    return (i < 2)? i: (Fib(i - 1) + Fib(i - 2));
}

template <uint32_t Z, uint32_t N> struct List
{
    const uint64_t val = Fib(Z - N);
    List<Z, N - 1> next;
};

template <uint32_t Z> struct List<Z, 0>
{
    const uint64_t value = Fib(Z - 0);
};

template <uint32_t Z> struct Array
{
    const List<Z - 1, Z - 1> data;
    const uint64_t *table = reinterpret_cast<const uint64_t*>(&data);
    constexpr uint32_t size() const { return Z; }
};

Array<20u> array;

int main()
{
    for (uint32_t i(0); i < array.size(); ++i)
        std::cout << array.table[i] << " ";
}


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/65312] Implicitly-declared default constructor must be defined as deleted
  2015-03-04 12:10 [Bug c++/65312] New: Implicitly-declared default constructor must be defined as deleted radventure at yandex dot ru
@ 2015-03-04 12:16 ` redi at gcc dot gnu.org
  2015-03-04 12:41 ` radventure at yandex dot ru
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2015-03-04 12:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I believe this is a GCC extension, G++ implements the proposed resolution of
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#253 and since all
sub-objects of List are correctly initialized, no initializer is required for
the member of that type.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/65312] Implicitly-declared default constructor must be defined as deleted
  2015-03-04 12:10 [Bug c++/65312] New: Implicitly-declared default constructor must be defined as deleted radventure at yandex dot ru
  2015-03-04 12:16 ` [Bug c++/65312] " redi at gcc dot gnu.org
@ 2015-03-04 12:41 ` radventure at yandex dot ru
  2015-03-16 10:50 ` mpolacek at gcc dot gnu.org
  2015-03-17  9:47 ` mpolacek at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: radventure at yandex dot ru @ 2015-03-04 12:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from radventure at yandex dot ru ---
(In reply to Jonathan Wakely from comment #1)
> I believe this is a GCC extension, G++ implements the proposed resolution of
> http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#253 and since
> all sub-objects of List are correctly initialized, no initializer is
> required for the member of that type.

Ok. Other question on a little bit another code. Why generated output so
dramatically changed when I removed initializer of 'data' member of Array
struct (//Here commented)

#include <cstdint>
#include <iostream>

constexpr uint64_t Fib(uint32_t i)
{
    return (i < 2)? i: (Fib(i - 1) + Fib(i - 2));
}

template <uint32_t Z, uint32_t N> struct List
{
    const uint64_t val = Fib(Z - N);
    const List<Z, N - 1> next{};
};

template <uint32_t Z> struct List<Z, 0>
{
    const uint64_t value = Fib(Z - 0);
};

template <uint32_t Z> struct Array
{
    const List<Z - 1, Z - 1> data{}; //Here
    const uint64_t *table = reinterpret_cast<const uint64_t*>(&data);
    constexpr uint32_t size() const { return Z; }
};

Array<20u> array;

int main()
{
    for (uint32_t i(0); i < array.size(); ++i)
        std::cout << array.table[i] << " ";
}


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/65312] Implicitly-declared default constructor must be defined as deleted
  2015-03-04 12:10 [Bug c++/65312] New: Implicitly-declared default constructor must be defined as deleted radventure at yandex dot ru
  2015-03-04 12:16 ` [Bug c++/65312] " redi at gcc dot gnu.org
  2015-03-04 12:41 ` radventure at yandex dot ru
@ 2015-03-16 10:50 ` mpolacek at gcc dot gnu.org
  2015-03-17  9:47 ` mpolacek at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-03-16 10:50 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org

--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Looks like this PR could be resolved as a NOTABUG?


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/65312] Implicitly-declared default constructor must be defined as deleted
  2015-03-04 12:10 [Bug c++/65312] New: Implicitly-declared default constructor must be defined as deleted radventure at yandex dot ru
                   ` (2 preceding siblings ...)
  2015-03-16 10:50 ` mpolacek at gcc dot gnu.org
@ 2015-03-17  9:47 ` mpolacek at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-03-17  9:47 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Closing then.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-03-17  9:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-04 12:10 [Bug c++/65312] New: Implicitly-declared default constructor must be defined as deleted radventure at yandex dot ru
2015-03-04 12:16 ` [Bug c++/65312] " redi at gcc dot gnu.org
2015-03-04 12:41 ` radventure at yandex dot ru
2015-03-16 10:50 ` mpolacek at gcc dot gnu.org
2015-03-17  9:47 ` mpolacek at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).