public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/96999] New: regression: std::variant requires default constructor with gcc 8-9, gcc 7.x and 10.x works
@ 2020-09-09 14:01 dushistov at mail dot ru
  2020-09-09 15:12 ` [Bug libstdc++/96999] [8/9 Regression] " redi at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: dushistov at mail dot ru @ 2020-09-09 14:01 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 96999
           Summary: regression: std::variant requires default constructor
                    with gcc 8-9, gcc 7.x and 10.x works
           Product: gcc
           Version: 9.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dushistov at mail dot ru
  Target Milestone: ---

For code bellow, gcc 9.3 from Ubuntu reports error:
```
In file included from /usr/include/c++/9/variant:36,
                 from test.cpp:1:
...
/usr/include/c++/9/type_traits:931:47: error: ‘Foo::Foo()’ is private within
this context                                                                    
  931 |     : public integral_constant<bool, noexcept(_Tp())>                   
      |                                               ^~~~~                     
test.cpp:10:3: note: declared private here                                      
   10 |   Foo() noexcept {}                                                     
      |   ^~~                       
```
gcc 8.x also reports error. gcc 7.x and 10.x works just fine:

```
#include <variant>
#include <string>

struct Foo {
public:
  explicit Foo(int) noexcept {}
  Foo(Foo &&) noexcept = default;
  Foo &operator=(Foo &&) = default;
private:
  Foo() noexcept {}
};

struct Boo {
public:
  explicit Boo(int) noexcept {}
  Boo(Boo &&) noexcept = default;
  Boo &operator=(Boo &&) = default;
private:
  Boo() noexcept {}
};


template<bool X>
std::variant<Foo, Boo> g(int v, int x) {
 return  v == 0 ? std::variant<Foo, Boo>{Foo{x}} :
                                 std::variant<Foo, Boo>{Boo{x}};
}

int main()
{
  std::variant<std::variant<Foo, Boo>, std::string> err{std::string("aaa")};
}
```

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

end of thread, other threads:[~2020-09-11 10:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-09 14:01 [Bug c++/96999] New: regression: std::variant requires default constructor with gcc 8-9, gcc 7.x and 10.x works dushistov at mail dot ru
2020-09-09 15:12 ` [Bug libstdc++/96999] [8/9 Regression] " redi at gcc dot gnu.org
2020-09-11 10:09 ` cvs-commit at gcc dot gnu.org
2020-09-11 10:53 ` cvs-commit at gcc dot gnu.org
2020-09-11 10:56 ` redi 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).