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++/80507] New: [C++17] static variable definition not emitted with -std=c++1z when defined as constexpr


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

            Bug ID: 80507
           Summary: [C++17] static variable definition not emitted with
                    -std=c++1z when defined as constexpr
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: arnaud02 at users dot sourceforge.net
  Target Milestone: ---

>g++ --version                                                                  g++ (GCC) 7.0.1 20170420 (prerelease)
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

>cat gcc7.cpp                                                                   struct CLS1 {
  int m_index;
  constexpr CLS1(int index) : m_index(index) {}
};

struct CLS2 {
  static const CLS1 s_IXXX;
};

constexpr_var_decld_const CLS1 CLS2::s_IXXX {-1};

># works fine in C++14 with const
>rm gcc7.o; g++ -std=c++14 -Dconstexpr_var_decld_const=const -c gcc7.cpp; nm -C gcc7.o
0000000000000000 R CLS2::s_IXXX
># works fine in C++14 with constexpr
>rm gcc7.o; g++ -std=c++14 -Dconstexpr_var_decld_const=constexpr -c gcc7.cpp; nm -C gcc7.o
0000000000000000 R CLS2::s_IXXX
># works fine in C++17 with const
>rm gcc7.o; g++ -std=c++1z -Dconstexpr_var_decld_const=const -c gcc7.cpp; nm -C gcc7.o
0000000000000000 R CLS2::s_IXXX
># does not work in C++17 with constexpr (static object in not created)
>rm gcc7.o; g++ -std=c++1z -Dconstexpr_var_decld_const=constexpr -c gcc7.cpp; nm -C gcc7.o

Using constexpr for variables forward declared as const has been handled by gcc
since gcc 4.9 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59123). This does
not work reliably with "-std=c++1z". It was accepted by gcc 6.2.

Could you address it please?

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