public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/109169] New: Feature request: Allow omitted template prompts
@ 2023-03-17  4:36 steve_green at qq dot com
  2023-03-17  4:41 ` [Bug c++/109169] " steve_green at qq dot com
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: steve_green at qq dot com @ 2023-03-17  4:36 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109169
           Summary: Feature request: Allow omitted template prompts
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: steve_green at qq dot com
  Target Milestone: ---

I have a third party library that has this write up
```c++
template<class T>
template struct type_info_t{
        //...
        template<class U>
        static constexpr bool can_convert_to=XXX;
        //...
}
template<class T>
constexpr type_info_t<T>type_info{};
```
Since msvc supports such writes, the form of `type_info<T>.can_convert_to<U>`,
`compare.able<T>`, `invoke<F>.nothrow<Args... >` are written throughout the
project.
Although this is not the standard way of writing, I would expect gcc to support
such code.

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

* [Bug c++/109169] Feature request: Allow omitted template prompts
  2023-03-17  4:36 [Bug c++/109169] New: Feature request: Allow omitted template prompts steve_green at qq dot com
@ 2023-03-17  4:41 ` steve_green at qq dot com
  2023-03-17  5:05 ` pinskia at gcc dot gnu.org
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: steve_green at qq dot com @ 2023-03-17  4:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from steve02081504 <steve_green at qq dot com> ---
(Corrected code)
```c++
template<class T>
struct type_info_t{
        //...
        template<class U>
        static constexpr bool can_convert_to=XXX;
        //...
};
template<class T>
constexpr type_info_t<T>type_info{};
```

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

* [Bug c++/109169] Feature request: Allow omitted template prompts
  2023-03-17  4:36 [Bug c++/109169] New: Feature request: Allow omitted template prompts steve_green at qq dot com
  2023-03-17  4:41 ` [Bug c++/109169] " steve_green at qq dot com
@ 2023-03-17  5:05 ` pinskia at gcc dot gnu.org
  2023-03-17  5:06 ` pinskia at gcc dot gnu.org
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-03-17  5:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
There is a defect report in this area of gcc.

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

* [Bug c++/109169] Feature request: Allow omitted template prompts
  2023-03-17  4:36 [Bug c++/109169] New: Feature request: Allow omitted template prompts steve_green at qq dot com
  2023-03-17  4:41 ` [Bug c++/109169] " steve_green at qq dot com
  2023-03-17  5:05 ` pinskia at gcc dot gnu.org
@ 2023-03-17  5:06 ` pinskia at gcc dot gnu.org
  2023-03-17  5:29 ` pinskia at gcc dot gnu.org
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-03-17  5:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #2)
> There is a defect report in this area of gcc.

Sorry c++

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

* [Bug c++/109169] Feature request: Allow omitted template prompts
  2023-03-17  4:36 [Bug c++/109169] New: Feature request: Allow omitted template prompts steve_green at qq dot com
                   ` (2 preceding siblings ...)
  2023-03-17  5:06 ` pinskia at gcc dot gnu.org
@ 2023-03-17  5:29 ` pinskia at gcc dot gnu.org
  2023-03-17  5:30 ` pinskia at gcc dot gnu.org
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-03-17  5:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
You provide a full example of what you want?
Because right now your example your provided does not even compile with msvc.

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

* [Bug c++/109169] Feature request: Allow omitted template prompts
  2023-03-17  4:36 [Bug c++/109169] New: Feature request: Allow omitted template prompts steve_green at qq dot com
                   ` (3 preceding siblings ...)
  2023-03-17  5:29 ` pinskia at gcc dot gnu.org
@ 2023-03-17  5:30 ` pinskia at gcc dot gnu.org
  2023-03-17  5:30 ` pinskia at gcc dot gnu.org
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-03-17  5:30 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I suspect the thing you are requesting is having the template keyword as being
optional but I am not sure.

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

* [Bug c++/109169] Feature request: Allow omitted template prompts
  2023-03-17  4:36 [Bug c++/109169] New: Feature request: Allow omitted template prompts steve_green at qq dot com
                   ` (4 preceding siblings ...)
  2023-03-17  5:30 ` pinskia at gcc dot gnu.org
@ 2023-03-17  5:30 ` pinskia at gcc dot gnu.org
  2023-03-17 15:13 ` steve_green at qq dot com
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-03-17  5:30 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2023-03-17

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

* [Bug c++/109169] Feature request: Allow omitted template prompts
  2023-03-17  4:36 [Bug c++/109169] New: Feature request: Allow omitted template prompts steve_green at qq dot com
                   ` (5 preceding siblings ...)
  2023-03-17  5:30 ` pinskia at gcc dot gnu.org
@ 2023-03-17 15:13 ` steve_green at qq dot com
  2023-03-17 15:16 ` steve_green at qq dot com
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: steve_green at qq dot com @ 2023-03-17 15:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from steve02081504 <steve_green at qq dot com> ---
Created attachment 54696
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54696&action=edit
temp.cpp

(In reply to Andrew Pinski from comment #4)
> You provide a full example of what you want?
> Because right now your example your provided does not even compile with msvc.

Strangely enough, when I tried to reproduce this requirement, I found that the
sample code I had written would compile.
```c++
#include <concepts>
template<class T>
struct A {
        template<class U>
        static constexpr bool a = ::std::is_base_of_v<T, U>;
};
template<class T>
A<T> a{};
int      main() {
        return a<int>.a<int>;
}
```
I had no choice but to attach the files I couldn't get to compile and pass in
the attachment.
I didn't understand whether gcc could compile such things or not......

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

* [Bug c++/109169] Feature request: Allow omitted template prompts
  2023-03-17  4:36 [Bug c++/109169] New: Feature request: Allow omitted template prompts steve_green at qq dot com
                   ` (6 preceding siblings ...)
  2023-03-17 15:13 ` steve_green at qq dot com
@ 2023-03-17 15:16 ` steve_green at qq dot com
  2023-03-17 16:35 ` pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: steve_green at qq dot com @ 2023-03-17 15:16 UTC (permalink / raw)
  To: gcc-bugs

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

steve02081504 <steve_green at qq dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|unknown                     |12.2.0

--- Comment #7 from steve02081504 <steve_green at qq dot com> ---
(error&version info)

```text
C:\Users\steve02081504\Documents\workstation\ELC_workdirs\ELC>x86_64-w64-mingw32-g++
-v
Using built-in specs.
COLLECT_GCC=E:\msys\mingw64\bin\x86_64-w64-mingw32-g++.exe
COLLECT_LTO_WRAPPER=E:/msys/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc-12.2.0/configure --prefix=/mingw64
--with-local-prefix=/mingw64/local --build=x86_64-w64-mingw32
--host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32
--with-native-system-header-dir=/mingw64/include --libexecdir=/mingw64/lib
--enable-bootstrap --enable-checking=release --with-arch=nocona
--with-tune=generic --enable-languages=c,lto,c++,fortran,ada,objc,obj-c++,jit
--enable-shared --enable-static --enable-libatomic --enable-threads=posix
--enable-graphite --enable-fully-dynamic-string
--enable-libstdcxx-filesystem-ts --enable-libstdcxx-time
--disable-libstdcxx-pch --enable-lto --enable-libgomp --disable-multilib
--disable-rpath --disable-win32-registry --disable-nls --disable-werror
--disable-symvers --with-libiconv --with-system-zlib --with-gmp=/mingw64
--with-mpfr=/mingw64 --with-mpc=/mingw64 --with-isl=/mingw64
--with-pkgversion='Rev10, Built by MSYS2 project'
--with-bugurl=https://github.com/msys2/MINGW-packages/issues --with-gnu-as
--with-gnu-ld --disable-libstdcxx-debug --with-boot-ldflags=-static-libstdc++
--with-stage1-ldflags=-static-libstdc++
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.2.0 (Rev10, Built by MSYS2 project)
C:\Users\steve02081504\Documents\workstation\ELC_workdirs\ELC>x86_64-w64-mingw32-g++
-x c++ -std=c++23 temp.cpp
In file included from
.\parts\header_file\files\elc\_files/base_defs/base_defs/_body.hpp:54,
                 from
.\parts\header_file\files\elc\_files/base_defs/_body.hpp:53,
                 from .\parts\header_file\files\elc\base_defs:50,
                 from .\parts\header_file\files\elc\random:33:
.\parts\header_file\files\elc\_files/base_defs/base_defs/hash.hpp:47:91: error:
expected primary-expression before '>' token
   47 |         concept is_unstable_hash = type_info<T
const>.can_convert_to<unstable_hash_value_t>;
      |                                                                        
                  ^
.\parts\header_file\files\elc\_files/base_defs/base_defs/hash.hpp:47:92: error:
expected primary-expression before ';' token
   47 |         concept is_unstable_hash = type_info<T
const>.can_convert_to<unstable_hash_value_t>;
      |                                                                        
                   ^
In file included from
.\parts\header_file\files\elc\_files/base_defs/base_defs/_body.hpp:55:
.\parts\header_file\files\elc\_files/base_defs/base_defs/range.hpp:50:74:
error: expected primary-expression before '>' token
   50 |                 template <class U>
requires(type_info<T>.can_convert_to<U>)
      |
```

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

* [Bug c++/109169] Feature request: Allow omitted template prompts
  2023-03-17  4:36 [Bug c++/109169] New: Feature request: Allow omitted template prompts steve_green at qq dot com
                   ` (7 preceding siblings ...)
  2023-03-17 15:16 ` steve_green at qq dot com
@ 2023-03-17 16:35 ` pinskia at gcc dot gnu.org
  2023-03-18  1:19 ` steve_green at qq dot com
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-03-17 16:35 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|---                         |WONTFIX

--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Yes we are not going to add a feature where template keyword can be omitted.
The reason is
type_info<T const>.can_convert_to<unstable_hash_value_t>;

Cis being parsed thinking < here is less than which is correct.

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

* [Bug c++/109169] Feature request: Allow omitted template prompts
  2023-03-17  4:36 [Bug c++/109169] New: Feature request: Allow omitted template prompts steve_green at qq dot com
                   ` (8 preceding siblings ...)
  2023-03-17 16:35 ` pinskia at gcc dot gnu.org
@ 2023-03-18  1:19 ` steve_green at qq dot com
  2023-03-18  1:26 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: steve_green at qq dot com @ 2023-03-18  1:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from steve02081504 <steve_green at qq dot com> ---
I don't quite understand why this is correct, can you elaborate on why and how
to change the code to bypass the error reporting?
Thanks.

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

* [Bug c++/109169] Feature request: Allow omitted template prompts
  2023-03-17  4:36 [Bug c++/109169] New: Feature request: Allow omitted template prompts steve_green at qq dot com
                   ` (9 preceding siblings ...)
  2023-03-18  1:19 ` steve_green at qq dot com
@ 2023-03-18  1:26 ` pinskia at gcc dot gnu.org
  2023-03-18  1:30 ` steve_green at qq dot com
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-03-18  1:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Take:
type_info<T const>.can_convert_to<unstable_hash_value_t>

The first part is dependent so when it goes to parse the next identifier, the
parser does not know that can_convert_to is a template or not.
So it thinks < is the less than operator rather than the start of a template
argument.

So the fix for the code is:
type_info<T const>.template can_convert_to<unstable_hash_value_t>

Which is the portable fix and even required by the standard to sign to the
compiler the next identifier will start naming of a template.

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

* [Bug c++/109169] Feature request: Allow omitted template prompts
  2023-03-17  4:36 [Bug c++/109169] New: Feature request: Allow omitted template prompts steve_green at qq dot com
                   ` (10 preceding siblings ...)
  2023-03-18  1:26 ` pinskia at gcc dot gnu.org
@ 2023-03-18  1:30 ` steve_green at qq dot com
  2023-03-18  1:40 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: steve_green at qq dot com @ 2023-03-18  1:30 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from steve02081504 <steve_green at qq dot com> ---
(In reply to Andrew Pinski from comment #10)
> Take:
> type_info<T const>.can_convert_to<unstable_hash_value_t>
> 
> The first part is dependent so when it goes to parse the next identifier,
> the parser does not know that can_convert_to is a template or not.
> So it thinks < is the less than operator rather than the start of a template
> argument.
> 
> So the fix for the code is:
> type_info<T const>.template can_convert_to<unstable_hash_value_t>
> 
> Which is the portable fix and even required by the standard to sign to the
> compiler the next identifier will start naming of a template.

I am not sure if I am making myself clear but msvc can compile such code and
that is the reason for my feature request?

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

* [Bug c++/109169] Feature request: Allow omitted template prompts
  2023-03-17  4:36 [Bug c++/109169] New: Feature request: Allow omitted template prompts steve_green at qq dot com
                   ` (11 preceding siblings ...)
  2023-03-18  1:30 ` steve_green at qq dot com
@ 2023-03-18  1:40 ` pinskia at gcc dot gnu.org
  2023-03-18  2:15 ` pinskia at gcc dot gnu.org
  2023-03-18  2:21 ` steve_green at qq dot com
  14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-03-18  1:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #12 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Right and I am saying it is hard to support in a parser.
That is exactly why the language requires the template keyword here is to
distinguish and help out the parser.
Basically I am saying the whole point of template here is to help the parser
out to figure out what it should be next otherwise it cannot figure out. How
msvc implements without it, I don't know and really don't care.

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

* [Bug c++/109169] Feature request: Allow omitted template prompts
  2023-03-17  4:36 [Bug c++/109169] New: Feature request: Allow omitted template prompts steve_green at qq dot com
                   ` (12 preceding siblings ...)
  2023-03-18  1:40 ` pinskia at gcc dot gnu.org
@ 2023-03-18  2:15 ` pinskia at gcc dot gnu.org
  2023-03-18  2:21 ` steve_green at qq dot com
  14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-03-18  2:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #13 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
See http://womble.decadent.org.uk/c++/template-faq.html#disambiguation also to
better understand the reason why GCC implements it this way and why it is hard
to implement this "extension" in all cases.

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

* [Bug c++/109169] Feature request: Allow omitted template prompts
  2023-03-17  4:36 [Bug c++/109169] New: Feature request: Allow omitted template prompts steve_green at qq dot com
                   ` (13 preceding siblings ...)
  2023-03-18  2:15 ` pinskia at gcc dot gnu.org
@ 2023-03-18  2:21 ` steve_green at qq dot com
  14 siblings, 0 replies; 16+ messages in thread
From: steve_green at qq dot com @ 2023-03-18  2:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #14 from steve02081504 <steve_green at qq dot com> ---
(In reply to Andrew Pinski from comment #13)
> See http://womble.decadent.org.uk/c++/template-faq.html#disambiguation also
> to better understand the reason why GCC implements it this way and why it is
> hard to implement this "extension" in all cases.

But I guess type_info<T>.some_class_name a; is not allowed, right?
Only in the case of decltype(type_info<T>)::name do we need to consider whether
this is a typename or a template, and in the case of type_info<T>.name this
should always be a template?

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

end of thread, other threads:[~2023-03-18  2:21 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-17  4:36 [Bug c++/109169] New: Feature request: Allow omitted template prompts steve_green at qq dot com
2023-03-17  4:41 ` [Bug c++/109169] " steve_green at qq dot com
2023-03-17  5:05 ` pinskia at gcc dot gnu.org
2023-03-17  5:06 ` pinskia at gcc dot gnu.org
2023-03-17  5:29 ` pinskia at gcc dot gnu.org
2023-03-17  5:30 ` pinskia at gcc dot gnu.org
2023-03-17  5:30 ` pinskia at gcc dot gnu.org
2023-03-17 15:13 ` steve_green at qq dot com
2023-03-17 15:16 ` steve_green at qq dot com
2023-03-17 16:35 ` pinskia at gcc dot gnu.org
2023-03-18  1:19 ` steve_green at qq dot com
2023-03-18  1:26 ` pinskia at gcc dot gnu.org
2023-03-18  1:30 ` steve_green at qq dot com
2023-03-18  1:40 ` pinskia at gcc dot gnu.org
2023-03-18  2:15 ` pinskia at gcc dot gnu.org
2023-03-18  2:21 ` steve_green at qq dot com

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).