public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/102045] New: constructor is not being instantiated
@ 2021-08-24 15:10 hanicka at hanicka dot net
  2021-08-24 15:17 ` [Bug c++/102045] " mpolacek at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: hanicka at hanicka dot net @ 2021-08-24 15:10 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102045
           Summary: constructor is not being instantiated
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hanicka at hanicka dot net
  Target Milestone: ---

this error is in 11.0+ (including current trunk) and wasn't in gcc-10, the
compiler won't emit std::span<char>::span<char&[N1]> symbol as it should

```
#include <span>

struct byte_writer: std::span<char> {
    using std::span<char>::span;
        //byte_writer(auto && arg): std::span<char>{arg} { }
        constexpr void do_something() noexcept {
                (void)this->empty();
        }
};

int main() {
        char array[1];
        auto writer = byte_writer{array};
        writer.do_something();
}
```

if you explicitly use the constructor (commented out) it will emit the symbol,
also the symbol is emitted if `using std::span<char>::span;` is added to the
type.

https://compiler-explorer.com/z/q8z833eqd

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

* [Bug c++/102045] constructor is not being instantiated
  2021-08-24 15:10 [Bug c++/102045] New: constructor is not being instantiated hanicka at hanicka dot net
@ 2021-08-24 15:17 ` mpolacek at gcc dot gnu.org
  2021-08-24 15:19 ` redi at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-08-24 15:17 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Started with r11-6736.  I'm not sure if this is a desirable side effect of that
change.  I'll try to reduce this.

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

* [Bug c++/102045] constructor is not being instantiated
  2021-08-24 15:10 [Bug c++/102045] New: constructor is not being instantiated hanicka at hanicka dot net
  2021-08-24 15:17 ` [Bug c++/102045] " mpolacek at gcc dot gnu.org
@ 2021-08-24 15:19 ` redi at gcc dot gnu.org
  2021-08-24 15:22 ` redi at gcc dot gnu.org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2021-08-24 15:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Hana Dusíková from comment #0)
> #include <span>
> 
> struct byte_writer: std::span<char> {
>     using std::span<char>::span;

N.B. this line should be commented out to reproduce the problem.

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

* [Bug c++/102045] constructor is not being instantiated
  2021-08-24 15:10 [Bug c++/102045] New: constructor is not being instantiated hanicka at hanicka dot net
  2021-08-24 15:17 ` [Bug c++/102045] " mpolacek at gcc dot gnu.org
  2021-08-24 15:19 ` redi at gcc dot gnu.org
@ 2021-08-24 15:22 ` redi at gcc dot gnu.org
  2021-08-24 15:22 ` [Bug c++/102045] [11/12 regression] " redi at gcc dot gnu.org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2021-08-24 15:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Reduced:

template<typename T>
struct span
{
  template<unsigned long N>
  constexpr span(T (&a)[N]) : data(a), len(N) { }

  constexpr bool empty() const { return len == 0; }

  T* data;
  unsigned long len;
};


struct byte_writer: span<char> {
        //byte_writer(auto && arg): std::span<char>{arg} { }
        constexpr void do_something() noexcept {
                (void)this->empty();
        }
};

int main() {
        char array[1];
        auto writer = byte_writer{array};
        writer.do_something();
}

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

* [Bug c++/102045] [11/12 regression] constructor is not being instantiated
  2021-08-24 15:10 [Bug c++/102045] New: constructor is not being instantiated hanicka at hanicka dot net
                   ` (2 preceding siblings ...)
  2021-08-24 15:22 ` redi at gcc dot gnu.org
@ 2021-08-24 15:22 ` redi at gcc dot gnu.org
  2021-08-24 17:07 ` ppalka at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2021-08-24 15:22 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |10.3.1
             Status|UNCONFIRMED                 |NEW
            Summary|constructor is not being    |[11/12 regression]
                   |instantiated                |constructor is not being
                   |                            |instantiated
   Target Milestone|---                         |11.3
           Keywords|                            |link-failure
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-08-24
      Known to fail|                            |11.2.0, 12.0

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

* [Bug c++/102045] [11/12 regression] constructor is not being instantiated
  2021-08-24 15:10 [Bug c++/102045] New: constructor is not being instantiated hanicka at hanicka dot net
                   ` (3 preceding siblings ...)
  2021-08-24 15:22 ` [Bug c++/102045] [11/12 regression] " redi at gcc dot gnu.org
@ 2021-08-24 17:07 ` ppalka at gcc dot gnu.org
  2021-08-25  7:39 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-08-24 17:07 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

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

--- Comment #4 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Slightly more reduced:

struct span {
  template<class T> constexpr span(T) { }
};

struct byte_writer : span { };

void f(char *p) {
  byte_writer w{p};
}

int main() { }


Removing 'constexpr' makes the the link succeed

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

* [Bug c++/102045] [11/12 regression] constructor is not being instantiated
  2021-08-24 15:10 [Bug c++/102045] New: constructor is not being instantiated hanicka at hanicka dot net
                   ` (4 preceding siblings ...)
  2021-08-24 17:07 ` ppalka at gcc dot gnu.org
@ 2021-08-25  7:39 ` rguenth at gcc dot gnu.org
  2022-03-27  0:24 ` jason at gcc dot gnu.org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-08-25  7:39 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2

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

* [Bug c++/102045] [11/12 regression] constructor is not being instantiated
  2021-08-24 15:10 [Bug c++/102045] New: constructor is not being instantiated hanicka at hanicka dot net
                   ` (5 preceding siblings ...)
  2021-08-25  7:39 ` rguenth at gcc dot gnu.org
@ 2022-03-27  0:24 ` jason at gcc dot gnu.org
  2022-03-27  3:24 ` jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jason at gcc dot gnu.org @ 2022-03-27  0:24 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |jason at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

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

* [Bug c++/102045] [11/12 regression] constructor is not being instantiated
  2021-08-24 15:10 [Bug c++/102045] New: constructor is not being instantiated hanicka at hanicka dot net
                   ` (6 preceding siblings ...)
  2022-03-27  0:24 ` jason at gcc dot gnu.org
@ 2022-03-27  3:24 ` jason at gcc dot gnu.org
  2022-03-28 13:37 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jason at gcc dot gnu.org @ 2022-03-27  3:24 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hewillk at gmail dot com

--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> ---
*** Bug 102654 has been marked as a duplicate of this bug. ***

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

* [Bug c++/102045] [11/12 regression] constructor is not being instantiated
  2021-08-24 15:10 [Bug c++/102045] New: constructor is not being instantiated hanicka at hanicka dot net
                   ` (7 preceding siblings ...)
  2022-03-27  3:24 ` jason at gcc dot gnu.org
@ 2022-03-28 13:37 ` cvs-commit at gcc dot gnu.org
  2022-03-28 19:13 ` [Bug c++/102045] [11 " cvs-commit at gcc dot gnu.org
  2022-03-28 19:15 ` jason at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-03-28 13:37 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:72bdfcb848327020f62f72405d72cf85650666e1

commit r12-7850-g72bdfcb848327020f62f72405d72cf85650666e1
Author: Jason Merrill <jason@redhat.com>
Date:   Sat Mar 26 20:38:54 2022 -0400

    c++: missing aggregate base ctor [PR102045]

    When make_base_init_ok changes a call to a complete constructor into a call
    to a base constructor, we were never marking the base ctor as used, so it
    didn't get emitted.

            PR c++/102045

    gcc/cp/ChangeLog:

            * call.cc (make_base_init_ok): Call make_used.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp1z/aggr-base12.C: New test.

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

* [Bug c++/102045] [11 regression] constructor is not being instantiated
  2021-08-24 15:10 [Bug c++/102045] New: constructor is not being instantiated hanicka at hanicka dot net
                   ` (8 preceding siblings ...)
  2022-03-28 13:37 ` cvs-commit at gcc dot gnu.org
@ 2022-03-28 19:13 ` cvs-commit at gcc dot gnu.org
  2022-03-28 19:15 ` jason at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-03-28 19:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:

https://gcc.gnu.org/g:14146bb58f279659279cd189bf95c3b0cb5fe1ac

commit r11-9705-g14146bb58f279659279cd189bf95c3b0cb5fe1ac
Author: Jason Merrill <jason@redhat.com>
Date:   Sat Mar 26 20:38:54 2022 -0400

    c++: missing aggregate base ctor [PR102045]

    When make_base_init_ok changes a call to a complete constructor into a call
    to a base constructor, we were never marking the base ctor as used, so it
    didn't get emitted.

            PR c++/102045

    gcc/cp/ChangeLog:

            * call.c (make_base_init_ok): Call make_used.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp1z/aggr-base12.C: New test.

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

* [Bug c++/102045] [11 regression] constructor is not being instantiated
  2021-08-24 15:10 [Bug c++/102045] New: constructor is not being instantiated hanicka at hanicka dot net
                   ` (9 preceding siblings ...)
  2022-03-28 19:13 ` [Bug c++/102045] [11 " cvs-commit at gcc dot gnu.org
@ 2022-03-28 19:15 ` jason at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: jason at gcc dot gnu.org @ 2022-03-28 19:15 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #8 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2022-03-28 19:15 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-24 15:10 [Bug c++/102045] New: constructor is not being instantiated hanicka at hanicka dot net
2021-08-24 15:17 ` [Bug c++/102045] " mpolacek at gcc dot gnu.org
2021-08-24 15:19 ` redi at gcc dot gnu.org
2021-08-24 15:22 ` redi at gcc dot gnu.org
2021-08-24 15:22 ` [Bug c++/102045] [11/12 regression] " redi at gcc dot gnu.org
2021-08-24 17:07 ` ppalka at gcc dot gnu.org
2021-08-25  7:39 ` rguenth at gcc dot gnu.org
2022-03-27  0:24 ` jason at gcc dot gnu.org
2022-03-27  3:24 ` jason at gcc dot gnu.org
2022-03-28 13:37 ` cvs-commit at gcc dot gnu.org
2022-03-28 19:13 ` [Bug c++/102045] [11 " cvs-commit at gcc dot gnu.org
2022-03-28 19:15 ` jason 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).