public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100381] New: new static_assert((std::__is_complete_or_unbounded(...)) failure from g++ 11.1.0
@ 2021-05-02 14:15 gilles.gouaillardet at gmail dot com
  2021-05-03  8:04 ` [Bug libstdc++/100381] [11/12 Regression] " rguenth at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: gilles.gouaillardet at gmail dot com @ 2021-05-02 14:15 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100381
           Summary: new
                    static_assert((std::__is_complete_or_unbounded(...))
                    failure from g++ 11.1.0
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gilles.gouaillardet at gmail dot com
  Target Milestone: ---

Created attachment 50732
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50732&action=edit
a reproducer that fails from g++ 11.1.0

g++ 11.1.0 is no more able to compile GROMACS, as reported at
https://gitlab.com/gromacs/gromacs/-/issues/4039

I trimmed the offending code into the attached and self-contained reproducer,
that fails to build with the following error:

$ g++ -c reproducer.cpp
In file included from
/home/users/gilles/local/gcc-11.1.0/include/c++/11.1.0/bits/move.h:57,
                 from
/home/users/gilles/local/gcc-11.1.0/include/c++/11.1.0/bits/stl_function.h:60,
                 from
/home/users/gilles/local/gcc-11.1.0/include/c++/11.1.0/functional:49,
                 from reproducer.cpp:1:
/home/users/gilles/local/gcc-11.1.0/include/c++/11.1.0/type_traits: In
instantiation of 'struct std::is_invocable_r<void,
{anonymous}::DensityFitting::subscribeToPreProcessingNotifications(MdModulesNotifier*)::<lambda(const
IndexGroupsAndNames&)>&, IndexGroupsAndNames>':
/home/users/gilles/local/gcc-11.1.0/include/c++/11.1.0/type_traits:3011:46:  
required from 'constexpr const bool std::is_invocable_r_v<void,
{anonymous}::DensityFitting::subscribeToPreProcessingNotifications(MdModulesNotifier*)::<lambda(const
IndexGroupsAndNames&)>&, IndexGroupsAndNames>'
/home/users/gilles/local/gcc-11.1.0/include/c++/11.1.0/bits/invoke.h:103:27:  
required by substitution of 'template<class _Res, class _Callable, class ...
_Args> constexpr std::enable_if_t<is_invocable_r_v<_Res, _Callable, _Args ...>,
_Res> std::__invoke_r(_Callable&&, _Args&& ...) [with _Res = void; _Callable =
{anonymous}::DensityFitting::subscribeToPreProcessingNotifications(MdModulesNotifier*)::<lambda(const
IndexGroupsAndNames&)>&; _Args = {IndexGroupsAndNames}]'
/home/users/gilles/local/gcc-11.1.0/include/c++/11.1.0/bits/std_function.h:291:30:
  required from 'static _Res std::_Function_handler<_Res(_ArgTypes ...),
_Functor>::_M_invoke(const std::_Any_data&, _ArgTypes&& ...) [with _Res = void;
_Functor =
{anonymous}::DensityFitting::subscribeToPreProcessingNotifications(MdModulesNotifier*)::<lambda(const
IndexGroupsAndNames&)>; _ArgTypes = {IndexGroupsAndNames}]'
/home/users/gilles/local/gcc-11.1.0/include/c++/11.1.0/bits/std_function.h:422:21:
  required from 'std::function<_Res(_ArgTypes ...)>::function(_Functor) [with
_Functor =
{anonymous}::DensityFitting::subscribeToPreProcessingNotifications(MdModulesNotifier*)::<lambda(const
IndexGroupsAndNames&)>; <template-parameter-2-2> = void;
<template-parameter-2-3> = void; _Res = void; _ArgTypes =
{IndexGroupsAndNames}]'
reproducer.cpp:55:56:   required from here
/home/users/gilles/local/gcc-11.1.0/include/c++/11.1.0/type_traits:2954:7:
error: static assertion failed: each argument type must be a complete class or
an unbounded array
 2954 |       static_assert((std::__is_complete_or_unbounded(
      |       ^~~~~~~~~~~~~
/home/users/gilles/local/gcc-11.1.0/include/c++/11.1.0/type_traits:2954:7:
note:
'std::__is_complete_or_unbounded<std::__type_identity<IndexGroupsAndNames>
>((std::__type_identity<IndexGroupsAndNames>{},
std::__type_identity<IndexGroupsAndNames>()))' evaluates to false
/home/users/gilles/local/gcc-11.1.0/include/c++/11.1.0/type_traits: In
instantiation of 'struct std::is_nothrow_invocable_r<void,
{anonymous}::DensityFitting::subscribeToPreProcessingNotifications(MdModulesNotifier*)::<lambda(const
IndexGroupsAndNames&)>&, IndexGroupsAndNames>':
/home/users/gilles/local/gcc-11.1.0/include/c++/11.1.0/type_traits:3016:54:  
required from 'constexpr const bool std::is_nothrow_invocable_r_v<void,
{anonymous}::DensityFitting::subscribeToPreProcessingNotifications(MdModulesNotifier*)::<lambda(const
IndexGroupsAndNames&)>&, IndexGroupsAndNames>'
/home/users/gilles/local/gcc-11.1.0/include/c++/11.1.0/bits/invoke.h:105:14:  
required from 'constexpr std::enable_if_t<is_invocable_r_v<_Res, _Callable,
_Args ...>, _Res> std::__invoke_r(_Callable&&, _Args&& ...) [with _Res = void;
_Callable =
{anonymous}::DensityFitting::subscribeToPreProcessingNotifications(MdModulesNotifier*)::<lambda(const
IndexGroupsAndNames&)>&; _Args = {IndexGroupsAndNames};
std::enable_if_t<is_invocable_r_v<_Res, _Callable, _Args ...>, _Res> = void]'
/home/users/gilles/local/gcc-11.1.0/include/c++/11.1.0/bits/std_function.h:291:30:
  required from 'static _Res std::_Function_handler<_Res(_ArgTypes ...),
_Functor>::_M_invoke(const std::_Any_data&, _ArgTypes&& ...) [with _Res = void;
_Functor =
{anonymous}::DensityFitting::subscribeToPreProcessingNotifications(MdModulesNotifier*)::<lambda(const
IndexGroupsAndNames&)>; _ArgTypes = {IndexGroupsAndNames}]'
/home/users/gilles/local/gcc-11.1.0/include/c++/11.1.0/bits/std_function.h:422:21:
  required from 'std::function<_Res(_ArgTypes ...)>::function(_Functor) [with
_Functor =
{anonymous}::DensityFitting::subscribeToPreProcessingNotifications(MdModulesNotifier*)::<lambda(const
IndexGroupsAndNames&)>; <template-parameter-2-2> = void;
<template-parameter-2-3> = void; _Res = void; _ArgTypes =
{IndexGroupsAndNames}]'
reproducer.cpp:55:56:   required from here
/home/users/gilles/local/gcc-11.1.0/include/c++/11.1.0/type_traits:2992:7:
error: static assertion failed: each argument type must be a complete class or
an unbounded array
 2992 |       static_assert((std::__is_complete_or_unbounded(
      |       ^~~~~~~~~~~~~
/home/users/gilles/local/gcc-11.1.0/include/c++/11.1.0/type_traits:2992:7:
note:
'std::__is_complete_or_unbounded<std::__type_identity<IndexGroupsAndNames>
>((std::__type_identity<IndexGroupsAndNames>{},
std::__type_identity<IndexGroupsAndNames>()))' evaluates to false


The same code can be compiled with previous g++ versions (and many other
compilers such as clang++).

A "fix" is to replace
class IndexGroupsAndNames;
with
class IndexGroupsAndNames {};


git bisect points to the following commit

commit c1fc9f6e10e646f01194c8f150affbc1cfbc404a
Author: Antony Polukhin <antoshkka@gmail.com>
Date:   Thu Sep 24 18:51:37 2020 +0100

    libstdc++: assert that type traits are not misused with incomplete types
[PR 71579]


Based on the commit message and me being illiterate in modern C++, I cannot
tell whether the reproducer is valid C++, or g++ is right about rejecting it.


Could you please assess the validity of the reproducer and rule g++ behavior
w.r.t modern C++ standard?

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

* [Bug libstdc++/100381] [11/12 Regression] new static_assert((std::__is_complete_or_unbounded(...)) failure from g++ 11.1.0
  2021-05-02 14:15 [Bug c++/100381] New: new static_assert((std::__is_complete_or_unbounded(...)) failure from g++ 11.1.0 gilles.gouaillardet at gmail dot com
@ 2021-05-03  8:04 ` rguenth at gcc dot gnu.org
  2021-07-28  7:06 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-05-03  8:04 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
          Component|c++                         |libstdc++
   Target Milestone|---                         |11.2
            Summary|new                         |[11/12 Regression] new
                   |static_assert((std::__is_co |static_assert((std::__is_co
                   |mplete_or_unbounded(...))   |mplete_or_unbounded(...))
                   |failure from g++ 11.1.0     |failure from g++ 11.1.0

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

* [Bug libstdc++/100381] [11/12 Regression] new static_assert((std::__is_complete_or_unbounded(...)) failure from g++ 11.1.0
  2021-05-02 14:15 [Bug c++/100381] New: new static_assert((std::__is_complete_or_unbounded(...)) failure from g++ 11.1.0 gilles.gouaillardet at gmail dot com
  2021-05-03  8:04 ` [Bug libstdc++/100381] [11/12 Regression] " rguenth at gcc dot gnu.org
@ 2021-07-28  7:06 ` rguenth at gcc dot gnu.org
  2021-07-28 10:43 ` redi at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-28  7:06 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|11.2                        |11.3

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 11.2 is being released, retargeting bugs to GCC 11.3

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

* [Bug libstdc++/100381] [11/12 Regression] new static_assert((std::__is_complete_or_unbounded(...)) failure from g++ 11.1.0
  2021-05-02 14:15 [Bug c++/100381] New: new static_assert((std::__is_complete_or_unbounded(...)) failure from g++ 11.1.0 gilles.gouaillardet at gmail dot com
  2021-05-03  8:04 ` [Bug libstdc++/100381] [11/12 Regression] " rguenth at gcc dot gnu.org
  2021-07-28  7:06 ` rguenth at gcc dot gnu.org
@ 2021-07-28 10:43 ` redi at gcc dot gnu.org
  2022-04-21  7:49 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2021-07-28 10:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This is almost certainly invalid code. Implementations are not required to
enforce the complete type precondition, so "other compilers don't reject it"
doesn't mean much. If the code has undefined behaviour then it's conforming to
accept it silently, or to reject it like this.

I haven't analyzed it in detail yet though.

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

* [Bug libstdc++/100381] [11/12 Regression] new static_assert((std::__is_complete_or_unbounded(...)) failure from g++ 11.1.0
  2021-05-02 14:15 [Bug c++/100381] New: new static_assert((std::__is_complete_or_unbounded(...)) failure from g++ 11.1.0 gilles.gouaillardet at gmail dot com
                   ` (2 preceding siblings ...)
  2021-07-28 10:43 ` redi at gcc dot gnu.org
@ 2022-04-21  7:49 ` rguenth at gcc dot gnu.org
  2023-05-29 10:04 ` [Bug libstdc++/100381] [11/12/13/14 " jakub at gcc dot gnu.org
  2024-03-27 12:21 ` redi at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-04-21  7:49 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|11.3                        |11.4

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 11.3 is being released, retargeting bugs to GCC 11.4.

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

* [Bug libstdc++/100381] [11/12/13/14 Regression] new static_assert((std::__is_complete_or_unbounded(...)) failure from g++ 11.1.0
  2021-05-02 14:15 [Bug c++/100381] New: new static_assert((std::__is_complete_or_unbounded(...)) failure from g++ 11.1.0 gilles.gouaillardet at gmail dot com
                   ` (3 preceding siblings ...)
  2022-04-21  7:49 ` rguenth at gcc dot gnu.org
@ 2023-05-29 10:04 ` jakub at gcc dot gnu.org
  2024-03-27 12:21 ` redi at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-05-29 10:04 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|11.4                        |11.5

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 11.4 is being released, retargeting bugs to GCC 11.5.

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

* [Bug libstdc++/100381] [11/12/13/14 Regression] new static_assert((std::__is_complete_or_unbounded(...)) failure from g++ 11.1.0
  2021-05-02 14:15 [Bug c++/100381] New: new static_assert((std::__is_complete_or_unbounded(...)) failure from g++ 11.1.0 gilles.gouaillardet at gmail dot com
                   ` (4 preceding siblings ...)
  2023-05-29 10:04 ` [Bug libstdc++/100381] [11/12/13/14 " jakub at gcc dot gnu.org
@ 2024-03-27 12:21 ` redi at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2024-03-27 12:21 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The code is definitely invalid.

Your code instantiates std::function<void(CallParameter)> where CallParameter
is IndexGroupsAndNames which is an incomplete type. Constructing a
std::function checks that the callable argument is invocable with the argument
types in the std::function's call signature, which is void(CallParameter).

That is done using std::is_invocable_r. The spec for std::is_invocable_r<R, Fn,
ArgTypes...> has this requirement:

"Fn, R, and all types in the template parameter pack ArgTypes shall be complete
types, cv void, or arrays of unknown bound."

So you're trying to construct std::function<void(IncompleteType)> which needs
to check if you can call a function with an argument of type IncompleteType,
which cannot be determined because the type might be non-copyable.

Using std::function<void(const CallParameter&)> would work, so would ensuring
the type is complete before trying to use it in a std::function call signature.

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

end of thread, other threads:[~2024-03-27 12:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-02 14:15 [Bug c++/100381] New: new static_assert((std::__is_complete_or_unbounded(...)) failure from g++ 11.1.0 gilles.gouaillardet at gmail dot com
2021-05-03  8:04 ` [Bug libstdc++/100381] [11/12 Regression] " rguenth at gcc dot gnu.org
2021-07-28  7:06 ` rguenth at gcc dot gnu.org
2021-07-28 10:43 ` redi at gcc dot gnu.org
2022-04-21  7:49 ` rguenth at gcc dot gnu.org
2023-05-29 10:04 ` [Bug libstdc++/100381] [11/12/13/14 " jakub at gcc dot gnu.org
2024-03-27 12:21 ` 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).