From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 18056385842B; Wed, 6 Apr 2022 13:01:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 18056385842B From: "oss.abde.sassi at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/105178] New: g++ incorrectly reports invalid use of incomplete type Date: Wed, 06 Apr 2022 13:01:57 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 11.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: oss.abde.sassi at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Apr 2022 13:01:58 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105178 Bug ID: 105178 Summary: g++ incorrectly reports invalid use of incomplete type Product: gcc Version: 11.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: oss.abde.sassi at gmail dot com Target Milestone: --- Created attachment 52761 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D52761&action=3Dedit self-contained small example to reproduce the error g++ 11.20.1 incorrectly reports an invalid use of incomplete type when compiling the attached code in main.cpp. Note that changing the `TransitionTo` class constructor to any of the follo= wing forms will make the compiler compile the code with no error: // These will not produce an error: TransitionTo() : data_{} { } TransitionTo(int number =3D 0, std::any data =3D {}) : data_{std::move(data= )} { } TransitionTo(int number, std::any data =3D {}) : data_{std::move(data)} { } Command used: ------------- gcc -v -save-temps -std=3Dc++17 -o test-incomplete-type main.cpp > cmdline-output.txt 2>&1 Output from command ------------------- Using built-in specs. COLLECT_GCC=3Dgcc COLLECT_LTO_WRAPPER=3D/usr/libexec/gcc/x86_64-redhat-linux/11/lto-wrapper OFFLOAD_TARGET_NAMES=3Dnvptx-none OFFLOAD_TARGET_DEFAULT=3D1 Target: x86_64-redhat-linux Configured with: ../configure --enable-bootstrap --enable-languages=3Dc,c++,fortran,objc,obj-c++,ada,go,d,lto --prefix=3D/usr --mandir=3D/usr/share/man --infodir=3D/usr/share/info --with-bugurl=3Dhttp://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=3Dposix --enable-checking=3Drelease --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=3Dgnu --enable-plugin --enable-initfini-array --with-isl=3D/builddir/build/BUILD/gcc-11.2.1-20220127/obj-x86_64-redhat-li= nux/isl-install --enable-offload-targets=3Dnvptx-none --without-cuda-driver --enable-gnu-indirect-function --enable-cet --with-tune=3Dgeneric --with-arch_32=3Di686 --build=3Dx86_64-redhat-linux --with-build-config=3Dbootstrap-lto --enable-link-serialization=3D1 Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 11.2.1 20220127 (Red Hat 11.2.1-9) (GCC)=20 COLLECT_GCC_OPTIONS=3D'-v' '-save-temps' '-std=3Dc++17' '-o' 'test-incomple= te-type' '-mtune=3Dgeneric' '-march=3Dx86-64' '-dumpdir' 'test-incomplete-type-' /usr/libexec/gcc/x86_64-redhat-linux/11/cc1plus -E -quiet -v -D_GNU_SOURCE main.cpp -mtune=3Dgeneric -march=3Dx86-64 -std=3Dc++17 -fpch-preprocess -o test-incomplete-type-main.ii ignoring nonexistent directory "/usr/lib/gcc/x86_64-redhat-linux/11/include-fixed" ignoring nonexistent directory "/usr/lib/gcc/x86_64-redhat-linux/11/../../../../x86_64-redhat-linux/includ= e" #include "..." search starts here: #include <...> search starts here: /usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11 /usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/x86_64-redha= t-linux /usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/backward /usr/lib/gcc/x86_64-redhat-linux/11/include /usr/local/include /usr/include End of search list. COLLECT_GCC_OPTIONS=3D'-v' '-save-temps' '-std=3Dc++17' '-o' 'test-incomple= te-type' '-mtune=3Dgeneric' '-march=3Dx86-64' '-dumpdir' 'test-incomplete-type-' /usr/libexec/gcc/x86_64-redhat-linux/11/cc1plus -fpreprocessed test-incomplete-type-main.ii -quiet -dumpdir test-incomplete-type- -dumpbase main.cpp -dumpbase-ext .cpp -mtune=3Dgeneric -march=3Dx86-64 -std=3Dc++17 -= version -o test-incomplete-type-main.s GNU C++17 (GCC) version 11.2.1 20220127 (Red Hat 11.2.1-9) (x86_64-redhat-linux) compiled by GNU C version 11.2.1 20220127 (Red Hat 11.2.1-9), GMP version 6.2.0, MPFR version 4.1.0-p13, MPC version 1.2.1, isl version isl-0.18-GMP GGC heuristics: --param ggc-min-expand=3D100 --param ggc-min-heapsize=3D131= 072 GNU C++17 (GCC) version 11.2.1 20220127 (Red Hat 11.2.1-9) (x86_64-redhat-linux) compiled by GNU C version 11.2.1 20220127 (Red Hat 11.2.1-9), GMP version 6.2.0, MPFR version 4.1.0-p13, MPC version 1.2.1, isl version isl-0.18-GMP GGC heuristics: --param ggc-min-expand=3D100 --param ggc-min-heapsize=3D131= 072 Compiler executable checksum: e80ddce1451d1b9471a6adee59f3d39d In file included from /usr/include/c++/11/bits/move.h:57, from /usr/include/c++/11/bits/stl_pair.h:59, from /usr/include/c++/11/utility:70, from /usr/include/c++/11/tuple:38, from main.cpp:3: /usr/include/c++/11/type_traits: In instantiation of =E2=80=98struct std::__and_ >, std::is_copy_constructible > >=E2=80=99: /usr/include/c++/11/type_traits:2215:11: required by substitution of =E2=80=98template using _Require =3D std::__enable_if_t >::value> [with _Cond =3D {std::__not_ >, std::is_copy_constructible >}]=E2=80=99 /usr/include/c++/11/any:187:8: required by substitution of =E2=80=98templ= ate std::any::any(_Tp&&) [with _Tp =3D const TransitionTo&; _VTp =3D TransitionTo; _Mgr =3D std::any::_Manager_external >; =3D ]=E2=80=99 /usr/include/c++/11/type_traits:946:30: required from =E2=80=98struct std::__is_constructible_impl, const TransitionTo&>=E2=80=99 /usr/include/c++/11/type_traits:977:12: required from =E2=80=98struct std::__is_copy_constructible_impl, true>=E2=80=99 /usr/include/c++/11/type_traits:984:12: required from =E2=80=98struct std::is_copy_constructible >=E2=80=99 /usr/include/c++/11/type_traits:3179:33: required from =E2=80=98constexpr= const bool std::is_copy_constructible_v >=E2=80=99 /usr/include/c++/11/variant:288:5: required from =E2=80=98constexpr const= bool std::__detail::__variant::_Traits, DoNothing>::_S_copy_ctor=E2=80=99 /usr/include/c++/11/variant:1317:11: required from =E2=80=98class std::variant, DoNothing>=E2=80=99 main.cpp:35:28: required from =E2=80=98struct OneOf, DoNothing>=E2=80=99 main.cpp:71:8: required from =E2=80=98struct Maybe >=E2=80=99 main.cpp:103:43: required from here /usr/include/c++/11/type_traits:152:12: error: invalid use of incomplete ty= pe =E2=80=98std::conditional >, std::__not_ > >::type=E2=80=99 {aka =E2= =80=98struct std::is_copy_constructible >=E2=80=99} 152 | struct __and_<_B1, _B2> | ^~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/bits/move.h:57, from /usr/include/c++/11/bits/stl_pair.h:59, from /usr/include/c++/11/utility:70, from /usr/include/c++/11/tuple:38, from main.cpp:3: /usr/include/c++/11/type_traits:984:12: note: declaration of =E2=80=98std::conditional >, std::__not_ > >::type=E2=80=99 {aka =E2= =80=98struct std::is_copy_constructible >=E2=80=99} 984 | struct is_copy_constructible | ^~~~~~~~~~~~~~~~~~~~~=