public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/102912] New: Not full support of const arguments in std::variant
@ 2021-10-24 13:15 fchelnokov at gmail dot com
  2021-10-24 14:12 ` [Bug libstdc++/102912] " hewillk at gmail dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: fchelnokov at gmail dot com @ 2021-10-24 13:15 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102912
           Summary: Not full support of const arguments in std::variant
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fchelnokov at gmail dot com
  Target Milestone: ---

This program is valid:
```
#include <string>
#include <variant>

using S = std::variant<const int, const std::string>;

int main() {
    S s(1);
    S u = s;

    S v("abc");
    S w = v;
}
```
but its compilation in GCC results in a long error:
```
In file included from <source>:2:
/opt/compiler-explorer/gcc-trunk-20211024/include/c++/12.0.0/variant: In
instantiation of 'constexpr std::__detail::__variant::_Variadic_union<_First,
_Rest ...>::_Variadic_union(std::in_place_index_t<_Np>, _Args&& ...) [with long
unsigned int _Np = 1; _Args = {const int&}; _First = const
std::__cxx11::basic_string<char>; _Rest = {}]':
/opt/compiler-explorer/gcc-trunk-20211024/include/c++/12.0.0/variant:409:4:  
required from 'constexpr std::__detail::__variant::_Variadic_union<_First,
_Rest ...>::_Variadic_union(std::in_place_index_t<_Np>, _Args&& ...) [with long
unsigned int _Np = 2; _Args = {const int&}; _First = const int; _Rest = {const
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>
>}]'
/opt/compiler-explorer/gcc-trunk-20211024/include/c++/12.0.0/bits/stl_construct.h:119:7:
  required from 'constexpr void std::_Construct(_Tp*, _Args&& ...) [with _Tp =
std::__detail::__variant::_Variadic_union<const int, const
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >
>; _Args = {const std::in_place_index_t<2>&, const int&}]'
...
Demo: https://gcc.godbolt.org/z/ocajj3aao

Related discussion: https://stackoverflow.com/q/69696170/7325599
```

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

end of thread, other threads:[~2021-11-04  9:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-24 13:15 [Bug libstdc++/102912] New: Not full support of const arguments in std::variant fchelnokov at gmail dot com
2021-10-24 14:12 ` [Bug libstdc++/102912] " hewillk at gmail dot com
2021-10-25  9:35 ` redi at gcc dot gnu.org
2021-11-01 23:56 ` [Bug libstdc++/102912] [12 Regression] " redi at gcc dot gnu.org
2021-11-02 12:36 ` redi at gcc dot gnu.org
2021-11-04  9:39 ` cvs-commit at gcc dot gnu.org
2021-11-04  9:45 ` 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).