public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/87512] Error: the type ‘const auto’ of ‘constexpr’ variable is not literal
       [not found] <bug-87512-4@http.gcc.gnu.org/bugzilla/>
@ 2023-01-25  9:26 ` coyorkdow at outlook dot com
  2023-01-25  9:27 ` coyorkdow at outlook dot com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: coyorkdow at outlook dot com @ 2023-01-25  9:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Guo Youtao <coyorkdow at outlook dot com> ---
Created attachment 54340
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54340&action=edit
the preprocessed file generated by g++-11

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

* [Bug c++/87512] Error: the type ‘const auto’ of ‘constexpr’ variable is not literal
       [not found] <bug-87512-4@http.gcc.gnu.org/bugzilla/>
  2023-01-25  9:26 ` [Bug c++/87512] Error: the type ‘const auto’ of ‘constexpr’ variable is not literal coyorkdow at outlook dot com
@ 2023-01-25  9:27 ` coyorkdow at outlook dot com
  2023-01-25 16:47 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: coyorkdow at outlook dot com @ 2023-01-25  9:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Guo Youtao <coyorkdow at outlook dot com> ---
This bug can still be triggered in gcc-11 and gcc-12.

Here are the codes (the preprocessed file is attached)
```
#include <type_traits>
#include <memory>

template <class Tp>
constexpr auto is_pointer_v = std::is_pointer<Tp>::value;

template <class Tp, decltype(&Tp::operator*)* = nullptr>
auto Wrap1(int) -> std::integral_constant<bool,
is_pointer_v<decltype(std::declval<Tp>().operator->())>>;

template <class Tp>
auto Wrap1(...) -> std::is_pointer<Tp>;

int main() {
  static_assert(!is_pointer_v<std::unique_ptr<int>>); // this line can compile
  static_assert(decltype(Wrap1<std::unique_ptr<int>>(0))::value); // error
  return 0;
}
```

The err msgs
```
% g++-11 a.cc -save-temps
a.cc: In instantiation of 'constexpr const auto is_pointer_v<int*>':
a.cc:8:49:   required by substitution of 'template<class Tp, decltype (&
Tp::operator*)* <anonymous> > std::integral_constant<bool,
is_pointer_v<decltype (declval<Tp>().operator->())> > Wrap1(int) [with Tp =
std::unique_ptr<int>; decltype (& Tp::operator*)* <anonymous> = <missing>]'
a.cc:15:53:   required from here
a.cc:5:16: error: the type 'const auto' of 'constexpr' variable
'is_pointer_v<int*>' is not literal
    5 | constexpr auto is_pointer_v = std::is_pointer<Tp>::value;
      |                ^~~~~~~~~~~~
a.cc:5:16: error: 'const auto is_pointer_v<int*>' has incomplete type
a.cc: In function 'int main()':
a.cc:15:59: error: static assertion failed
   15 |   static_assert(decltype(Wrap1<std::unique_ptr<int>>(0))::value); //
this line incurs error
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
```


GCC version:
```
% gcc-11 -v
Using built-in specs.
COLLECT_GCC=gcc-11
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/11.3.0_2/bin/../libexec/gcc/x86_64-apple-darwin21/11/lto-wrapper
Target: x86_64-apple-darwin21
Configured with: ../configure --prefix=/usr/local/opt/gcc
--libdir=/usr/local/opt/gcc/lib/gcc/11 --disable-nls --enable-checking=release
--with-gcc-major-version-only --enable-languages=c,c++,objc,obj-c++,fortran,d
--program-suffix=-11 --with-gmp=/usr/local/opt/gmp
--with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc
--with-isl=/usr/local/opt/isl --with-zstd=/usr/local/opt/zstd
--with-pkgversion='Homebrew GCC 11.3.0_2'
--with-bugurl=https://github.com/Homebrew/homebrew-core/issues
--enable-libphobos --build=x86_64-apple-darwin21 --with-system-zlib
--with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.3.0 (Homebrew GCC 11.3.0_2)
```

If remove the parameter `decltype(&Tp::operator*)* = nullptr` then codes can be
compiled.

The error also happens in gcc-12.

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

* [Bug c++/87512] Error: the type ‘const auto’ of ‘constexpr’ variable is not literal
       [not found] <bug-87512-4@http.gcc.gnu.org/bugzilla/>
  2023-01-25  9:26 ` [Bug c++/87512] Error: the type ‘const auto’ of ‘constexpr’ variable is not literal coyorkdow at outlook dot com
  2023-01-25  9:27 ` coyorkdow at outlook dot com
@ 2023-01-25 16:47 ` pinskia at gcc dot gnu.org
  2023-01-25 16:53 ` coyorkdow at outlook dot com
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-01-25 16:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Guo Youtao from comment #5)
> This bug can still be triggered in gcc-11 and gcc-12.

That is unrelated bug. Most likely an issue with pointer to member functions
which is might have some known issues too.

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

* [Bug c++/87512] Error: the type ‘const auto’ of ‘constexpr’ variable is not literal
       [not found] <bug-87512-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2023-01-25 16:47 ` pinskia at gcc dot gnu.org
@ 2023-01-25 16:53 ` coyorkdow at outlook dot com
  2023-01-25 17:51 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: coyorkdow at outlook dot com @ 2023-01-25 16:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Guo Youtao <coyorkdow at outlook dot com> ---
(In reply to Andrew Pinski from comment #6)
> (In reply to Guo Youtao from comment #5)
> > This bug can still be triggered in gcc-11 and gcc-12.
> 
> That is unrelated bug. Most likely an issue with pointer to member functions
> which is might have some known issues too.

Should I open a new topic for this bug since this is unrelated?

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

* [Bug c++/87512] Error: the type ‘const auto’ of ‘constexpr’ variable is not literal
       [not found] <bug-87512-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2023-01-25 16:53 ` coyorkdow at outlook dot com
@ 2023-01-25 17:51 ` redi at gcc dot gnu.org
  2023-01-26  6:27 ` coyorkdow at outlook dot com
  2023-01-27  0:25 ` pinskia at gcc dot gnu.org
  6 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2023-01-25 17:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Yes please

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

* [Bug c++/87512] Error: the type ‘const auto’ of ‘constexpr’ variable is not literal
       [not found] <bug-87512-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2023-01-25 17:51 ` redi at gcc dot gnu.org
@ 2023-01-26  6:27 ` coyorkdow at outlook dot com
  2023-01-27  0:25 ` pinskia at gcc dot gnu.org
  6 siblings, 0 replies; 7+ messages in thread
From: coyorkdow at outlook dot com @ 2023-01-26  6:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Guo Youtao <coyorkdow at outlook dot com> ---
(In reply to Jonathan Wakely from comment #8)
> Yes please

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

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

* [Bug c++/87512] Error: the type ‘const auto’ of ‘constexpr’ variable is not literal
       [not found] <bug-87512-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2023-01-26  6:27 ` coyorkdow at outlook dot com
@ 2023-01-27  0:25 ` pinskia at gcc dot gnu.org
  6 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-01-27  0:25 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |9.0

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

end of thread, other threads:[~2023-01-27  0:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-87512-4@http.gcc.gnu.org/bugzilla/>
2023-01-25  9:26 ` [Bug c++/87512] Error: the type ‘const auto’ of ‘constexpr’ variable is not literal coyorkdow at outlook dot com
2023-01-25  9:27 ` coyorkdow at outlook dot com
2023-01-25 16:47 ` pinskia at gcc dot gnu.org
2023-01-25 16:53 ` coyorkdow at outlook dot com
2023-01-25 17:51 ` redi at gcc dot gnu.org
2023-01-26  6:27 ` coyorkdow at outlook dot com
2023-01-27  0:25 ` pinskia 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).