public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99901] New: static const class var implemented with constexpr doesn't emit symbols in C++17 mode
@ 2021-04-04  0:37 tellowkrinkle at gmail dot com
  2021-04-06  3:18 ` [Bug c++/99901] [8/9/10/11 Regression] " ppalka at gcc dot gnu.org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: tellowkrinkle at gmail dot com @ 2021-04-04  0:37 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 99901
           Summary: static const class var implemented with constexpr
                    doesn't emit symbols in C++17 mode
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tellowkrinkle at gmail dot com
  Target Milestone: ---

The following code fails to output any symbols when compiled with `-std=c++17`:

struct A {
    static const int a;
};
constexpr int A::a = 5;

Godbolt link: https://gcc.godbolt.org/z/13efnK4x4

You can run this in a way that results in a linker error with the following:

a.h:
#pragma once
struct A { static const int a; };

a.cpp:
#include "a.h"
constexpr int A::a = 0;

main.cpp:
#include "a.h"
int main() { return A::a; }

Works fine when compiled with `g++ main.cpp a.cpp`
Fails when compiled with `g++ -std=c++17 main.cpp a.cpp`

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

* [Bug c++/99901] [8/9/10/11 Regression] static const class var implemented with constexpr doesn't emit symbols in C++17 mode
  2021-04-04  0:37 [Bug c++/99901] New: static const class var implemented with constexpr doesn't emit symbols in C++17 mode tellowkrinkle at gmail dot com
@ 2021-04-06  3:18 ` ppalka at gcc dot gnu.org
  2021-04-06  5:19 ` jason at gcc dot gnu.org
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-04-06  3:18 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |8.5
     Ever confirmed|0                           |1
           Keywords|                            |wrong-code
             Status|UNCONFIRMED                 |NEW
                 CC|                            |jakub at gcc dot gnu.org,
                   |                            |jason at gcc dot gnu.org,
                   |                            |ppalka at gcc dot gnu.org
   Last reconfirmed|                            |2021-04-06
            Summary|static const class var      |[8/9/10/11 Regression]
                   |implemented with constexpr  |static const class var
                   |doesn't emit symbols in     |implemented with constexpr
                   |C++17 mode                  |doesn't emit symbols in
                   |                            |C++17 mode

--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Confirmed.  Seems to have started with r7-3808.

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

* [Bug c++/99901] [8/9/10/11 Regression] static const class var implemented with constexpr doesn't emit symbols in C++17 mode
  2021-04-04  0:37 [Bug c++/99901] New: static const class var implemented with constexpr doesn't emit symbols in C++17 mode tellowkrinkle at gmail dot com
  2021-04-06  3:18 ` [Bug c++/99901] [8/9/10/11 Regression] " ppalka at gcc dot gnu.org
@ 2021-04-06  5:19 ` jason at gcc dot gnu.org
  2021-04-06 18:30 ` cvs-commit at gcc dot gnu.org
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu.org @ 2021-04-06  5:19 UTC (permalink / raw)
  To: gcc-bugs

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

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] 14+ messages in thread

* [Bug c++/99901] [8/9/10/11 Regression] static const class var implemented with constexpr doesn't emit symbols in C++17 mode
  2021-04-04  0:37 [Bug c++/99901] New: static const class var implemented with constexpr doesn't emit symbols in C++17 mode tellowkrinkle at gmail dot com
  2021-04-06  3:18 ` [Bug c++/99901] [8/9/10/11 Regression] " ppalka at gcc dot gnu.org
  2021-04-06  5:19 ` jason at gcc dot gnu.org
@ 2021-04-06 18:30 ` cvs-commit at gcc dot gnu.org
  2021-04-06 18:32 ` [Bug c++/99901] [8/9/10 " jason at gcc dot gnu.org
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-06 18:30 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 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:8685348075d91945066dea9b564bd42cbc1d22bd

commit r11-8017-g8685348075d91945066dea9b564bd42cbc1d22bd
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Apr 6 01:21:05 2021 -0400

    c++: C++17 constexpr static data member linkage [PR99901]

    C++17 makes constexpr static data members implicitly inline variables.  In
    C++14, a subsequent out-of-class declaration is the definition.  We want to
    continue emitting a symbol for such a declaration in C++17 mode, for ABI
    compatibility with C++14 code that wants to refer to it.

    Normally I'd distinguish in- and out-of-class declarations by looking at
    DECL_IN_AGGR_P, but we never set DECL_IN_AGGR_P on inline variables.  I
    think that's wrong, but don't want to mess with it so close to release.
    Conveniently, we already have a test for in-class declaration earlier in
the
    function.

    gcc/cp/ChangeLog:

            PR c++/99901
            * decl.c (cp_finish_decl): mark_needed an implicitly inline
            static data member with an out-of-class redeclaration.

    gcc/testsuite/ChangeLog:

            PR c++/99901
            * g++.dg/cpp1z/inline-var9.C: New test.

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

* [Bug c++/99901] [8/9/10 Regression] static const class var implemented with constexpr doesn't emit symbols in C++17 mode
  2021-04-04  0:37 [Bug c++/99901] New: static const class var implemented with constexpr doesn't emit symbols in C++17 mode tellowkrinkle at gmail dot com
                   ` (2 preceding siblings ...)
  2021-04-06 18:30 ` cvs-commit at gcc dot gnu.org
@ 2021-04-06 18:32 ` jason at gcc dot gnu.org
  2021-04-30  8:09 ` rguenth at gcc dot gnu.org
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu.org @ 2021-04-06 18:32 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |11.0
           Keywords|wrong-code                  |ABI
            Summary|[8/9/10/11 Regression]      |[8/9/10 Regression] static
                   |static const class var      |const class var implemented
                   |implemented with constexpr  |with constexpr doesn't emit
                   |doesn't emit symbols in     |symbols in C++17 mode
                   |C++17 mode                  |

--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for 11 so far.

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

* [Bug c++/99901] [8/9/10 Regression] static const class var implemented with constexpr doesn't emit symbols in C++17 mode
  2021-04-04  0:37 [Bug c++/99901] New: static const class var implemented with constexpr doesn't emit symbols in C++17 mode tellowkrinkle at gmail dot com
                   ` (3 preceding siblings ...)
  2021-04-06 18:32 ` [Bug c++/99901] [8/9/10 " jason at gcc dot gnu.org
@ 2021-04-30  8:09 ` rguenth at gcc dot gnu.org
  2021-05-14  9:54 ` [Bug c++/99901] [9/10 " jakub at gcc dot gnu.org
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-04-30  8:09 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

* [Bug c++/99901] [9/10 Regression] static const class var implemented with constexpr doesn't emit symbols in C++17 mode
  2021-04-04  0:37 [Bug c++/99901] New: static const class var implemented with constexpr doesn't emit symbols in C++17 mode tellowkrinkle at gmail dot com
                   ` (4 preceding siblings ...)
  2021-04-30  8:09 ` rguenth at gcc dot gnu.org
@ 2021-05-14  9:54 ` jakub at gcc dot gnu.org
  2021-05-20 21:35 ` cvs-commit at gcc dot gnu.org
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-05-14  9:54 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|8.5                         |9.4

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 8 branch is being closed.

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

* [Bug c++/99901] [9/10 Regression] static const class var implemented with constexpr doesn't emit symbols in C++17 mode
  2021-04-04  0:37 [Bug c++/99901] New: static const class var implemented with constexpr doesn't emit symbols in C++17 mode tellowkrinkle at gmail dot com
                   ` (5 preceding siblings ...)
  2021-05-14  9:54 ` [Bug c++/99901] [9/10 " jakub at gcc dot gnu.org
@ 2021-05-20 21:35 ` cvs-commit at gcc dot gnu.org
  2021-06-01  8:20 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-05-20 21:35 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:5b68416a940b32b739cdc033e018bab5161a721d

commit r10-9847-g5b68416a940b32b739cdc033e018bab5161a721d
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Apr 6 01:21:05 2021 -0400

    c++: C++17 constexpr static data member linkage [PR99901]

    C++17 makes constexpr static data members implicitly inline variables.  In
    C++14, a subsequent out-of-class declaration is the definition.  We want to
    continue emitting a symbol for such a declaration in C++17 mode, for ABI
    compatibility with C++14 code that wants to refer to it.

    Normally I'd distinguish in- and out-of-class declarations by looking at
    DECL_IN_AGGR_P, but we never set DECL_IN_AGGR_P on inline variables.  I
    think that's wrong, but don't want to mess with it so close to release.
    Conveniently, we already have a test for in-class declaration earlier in
the
    function.

    gcc/cp/ChangeLog:

            PR c++/99901
            * decl.c (cp_finish_decl): mark_needed an implicitly inline
            static data member with an out-of-class redeclaration.

    gcc/testsuite/ChangeLog:

            PR c++/99901
            * g++.dg/cpp1z/inline-var9.C: New test.

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

* [Bug c++/99901] [9/10 Regression] static const class var implemented with constexpr doesn't emit symbols in C++17 mode
  2021-04-04  0:37 [Bug c++/99901] New: static const class var implemented with constexpr doesn't emit symbols in C++17 mode tellowkrinkle at gmail dot com
                   ` (6 preceding siblings ...)
  2021-05-20 21:35 ` cvs-commit at gcc dot gnu.org
@ 2021-06-01  8:20 ` rguenth at gcc dot gnu.org
  2021-08-06 10:35 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-01  8:20 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|9.4                         |9.5

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 9.4 is being released, retargeting bugs to GCC 9.5.

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

* [Bug c++/99901] [9/10 Regression] static const class var implemented with constexpr doesn't emit symbols in C++17 mode
  2021-04-04  0:37 [Bug c++/99901] New: static const class var implemented with constexpr doesn't emit symbols in C++17 mode tellowkrinkle at gmail dot com
                   ` (7 preceding siblings ...)
  2021-06-01  8:20 ` rguenth at gcc dot gnu.org
@ 2021-08-06 10:35 ` jakub at gcc dot gnu.org
  2021-08-27 23:31 ` [Bug c++/99901] [9 " pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-08-06 10:35 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |koncek.marian at gmail dot com

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
*** Bug 101800 has been marked as a duplicate of this bug. ***

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

* [Bug c++/99901] [9 Regression] static const class var implemented with constexpr doesn't emit symbols in C++17 mode
  2021-04-04  0:37 [Bug c++/99901] New: static const class var implemented with constexpr doesn't emit symbols in C++17 mode tellowkrinkle at gmail dot com
                   ` (8 preceding siblings ...)
  2021-08-06 10:35 ` jakub at gcc dot gnu.org
@ 2021-08-27 23:31 ` pinskia at gcc dot gnu.org
  2021-08-28  0:09 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-27 23:31 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |arnaud02 at users dot sourceforge.
                   |                            |net

--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 80507 has been marked as a duplicate of this bug. ***

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

* [Bug c++/99901] [9 Regression] static const class var implemented with constexpr doesn't emit symbols in C++17 mode
  2021-04-04  0:37 [Bug c++/99901] New: static const class var implemented with constexpr doesn't emit symbols in C++17 mode tellowkrinkle at gmail dot com
                   ` (9 preceding siblings ...)
  2021-08-27 23:31 ` [Bug c++/99901] [9 " pinskia at gcc dot gnu.org
@ 2021-08-28  0:09 ` pinskia at gcc dot gnu.org
  2022-05-13 17:41 ` cvs-commit at gcc dot gnu.org
  2022-05-13 17:49 ` jason at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-28  0:09 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

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

--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 90161 has been marked as a duplicate of this bug. ***

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

* [Bug c++/99901] [9 Regression] static const class var implemented with constexpr doesn't emit symbols in C++17 mode
  2021-04-04  0:37 [Bug c++/99901] New: static const class var implemented with constexpr doesn't emit symbols in C++17 mode tellowkrinkle at gmail dot com
                   ` (10 preceding siblings ...)
  2021-08-28  0:09 ` pinskia at gcc dot gnu.org
@ 2022-05-13 17:41 ` cvs-commit at gcc dot gnu.org
  2022-05-13 17:49 ` jason at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-13 17:41 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:623842bead8452c03f2b1c6817f2a86a1d2d4d12

commit r9-10169-g623842bead8452c03f2b1c6817f2a86a1d2d4d12
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Apr 6 01:21:05 2021 -0400

    c++: C++17 constexpr static data member linkage [PR99901]

    C++17 makes constexpr static data members implicitly inline variables.  In
    C++14, a subsequent out-of-class declaration is the definition.  We want to
    continue emitting a symbol for such a declaration in C++17 mode, for ABI
    compatibility with C++14 code that wants to refer to it.

    Normally I'd distinguish in- and out-of-class declarations by looking at
    DECL_IN_AGGR_P, but we never set DECL_IN_AGGR_P on inline variables.  I
    think that's wrong, but don't want to mess with it so close to release.
    Conveniently, we already have a test for in-class declaration earlier in
the
    function.

    gcc/cp/ChangeLog:

            PR c++/99901
            * decl.c (cp_finish_decl): mark_needed an implicitly inline
            static data member with an out-of-class redeclaration.

    gcc/testsuite/ChangeLog:

            PR c++/99901
            * g++.dg/cpp1z/inline-var9.C: New test.

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

* [Bug c++/99901] [9 Regression] static const class var implemented with constexpr doesn't emit symbols in C++17 mode
  2021-04-04  0:37 [Bug c++/99901] New: static const class var implemented with constexpr doesn't emit symbols in C++17 mode tellowkrinkle at gmail dot com
                   ` (11 preceding siblings ...)
  2022-05-13 17:41 ` cvs-commit at gcc dot gnu.org
@ 2022-05-13 17:49 ` jason at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu.org @ 2022-05-13 17:49 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #11 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for 9.5/10.4/11.

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

end of thread, other threads:[~2022-05-13 17:49 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-04  0:37 [Bug c++/99901] New: static const class var implemented with constexpr doesn't emit symbols in C++17 mode tellowkrinkle at gmail dot com
2021-04-06  3:18 ` [Bug c++/99901] [8/9/10/11 Regression] " ppalka at gcc dot gnu.org
2021-04-06  5:19 ` jason at gcc dot gnu.org
2021-04-06 18:30 ` cvs-commit at gcc dot gnu.org
2021-04-06 18:32 ` [Bug c++/99901] [8/9/10 " jason at gcc dot gnu.org
2021-04-30  8:09 ` rguenth at gcc dot gnu.org
2021-05-14  9:54 ` [Bug c++/99901] [9/10 " jakub at gcc dot gnu.org
2021-05-20 21:35 ` cvs-commit at gcc dot gnu.org
2021-06-01  8:20 ` rguenth at gcc dot gnu.org
2021-08-06 10:35 ` jakub at gcc dot gnu.org
2021-08-27 23:31 ` [Bug c++/99901] [9 " pinskia at gcc dot gnu.org
2021-08-28  0:09 ` pinskia at gcc dot gnu.org
2022-05-13 17:41 ` cvs-commit at gcc dot gnu.org
2022-05-13 17:49 ` 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).