public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/44906] g++ is giving error: parse error in template argument list while using a c++ code.
       [not found] <bug-44906-4@http.gcc.gnu.org/bugzilla/>
@ 2011-09-23 12:55 ` paolo.carlini at oracle dot com
  2011-09-23 14:11 ` manu at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 5+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-09-23 12:55 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44906

Paolo Carlini <paolo.carlini at oracle dot com> changed:

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

--- Comment #7 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-09-23 12:43:53 UTC ---
Closing as invalid.


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

* [Bug c++/44906] g++ is giving error: parse error in template argument list while using a c++ code.
       [not found] <bug-44906-4@http.gcc.gnu.org/bugzilla/>
  2011-09-23 12:55 ` [Bug c++/44906] g++ is giving error: parse error in template argument list while using a c++ code paolo.carlini at oracle dot com
@ 2011-09-23 14:11 ` manu at gcc dot gnu.org
  2011-09-23 14:53 ` paolo.carlini at oracle dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 5+ messages in thread
From: manu at gcc dot gnu.org @ 2011-09-23 14:11 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44906

--- Comment #8 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2011-09-23 13:59:07 UTC ---
(In reply to comment #6)
> Honestly, nothing similar will happen any time soon, it means changing
> completely the semantics of templates. Maybe we can produce a better
> diagnostics, let's add Manuel in CC to hear his opinion...

The code is invalid but the diagnostic could be much better (I only have GCC
4.5.2, so perhaps it is better in trunk).

Smaller testcase:

template<typename T>
class MISC{
public:
    T vec1;
    template<T* vc> void addVecVals(){};
    void add(void) { addVecVals<&vec1>();  };
};

void foo(void) {
    MISC<int> m;
    m.add();
}

Clang++ gives a somewhat better message:

/tmp/webcompile/_14512_0.cc:6:22: error: no matching member function for call
to 'addVecVals'
    void add(void) { addVecVals<&vec1>();  };
                     ^~~~~~~~~~~~~~~~~
/tmp/webcompile/_14512_0.cc:11:7: note: in instantiation of member function
'MISC<int>::add' requested here
    m.add();
      ^
/tmp/webcompile/_14512_0.cc:5:26: note: candidate template ignored: invalid
explicitly-specified argument for template parameter 'vc'
    template<T* vc> void addVecVals(){};
                         ^
1 error generated.


I would argue for reopening it...


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

* [Bug c++/44906] g++ is giving error: parse error in template argument list while using a c++ code.
       [not found] <bug-44906-4@http.gcc.gnu.org/bugzilla/>
  2011-09-23 12:55 ` [Bug c++/44906] g++ is giving error: parse error in template argument list while using a c++ code paolo.carlini at oracle dot com
  2011-09-23 14:11 ` manu at gcc dot gnu.org
@ 2011-09-23 14:53 ` paolo.carlini at oracle dot com
  2011-10-19 22:24 ` [Bug c++/44906] g++ is giving error: parse error in template argument list manu at gcc dot gnu.org
  2021-08-04  6:20 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 5+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-09-23 14:53 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44906

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
   Last reconfirmed|                            |2011-09-23
         Resolution|INVALID                     |
     Ever Confirmed|0                           |1

--- Comment #9 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-09-23 14:43:26 UTC ---
Hey, you woke up! ;) Sure, let's re-open is a diagnostic issue, your call.


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

* [Bug c++/44906] g++ is giving error: parse error in template argument list
       [not found] <bug-44906-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2011-09-23 14:53 ` paolo.carlini at oracle dot com
@ 2011-10-19 22:24 ` manu at gcc dot gnu.org
  2021-08-04  6:20 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 5+ messages in thread
From: manu at gcc dot gnu.org @ 2011-10-19 22:24 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44906

--- Comment #10 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2011-10-19 22:24:12 UTC ---
The problem seems to be the tentative parsing in cp_parse_template_id, which
tries every crazy thing it can, and when nothing works, it just gives this
catch all diagnostic. 

But debugging the C++ parser is an absolute pain, I hope someone with more
patience takes a shot at this. The current diagnostic is just awful.


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

* [Bug c++/44906] g++ is giving error: parse error in template argument list
       [not found] <bug-44906-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2011-10-19 22:24 ` [Bug c++/44906] g++ is giving error: parse error in template argument list manu at gcc dot gnu.org
@ 2021-08-04  6:20 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-04  6:20 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |NEW
   Last reconfirmed|2011-09-23 00:00:00         |2021-8-3

--- Comment #11 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
For the testcase in comment #8:

Ok, this is interesting as at first I thought this was fixed in GCC 11 but then
I looked to see what the different standards do as GCC 11's default is C++17.

With C++17 and C++20, we get:
<source>:8:34: error: use of 'this' in a constant expression
    8 |     void add(void) { addVecVals<&vec1>();  }
      |                                  ^~~~
<source>: In instantiation of 'void MISC<T>::add() [with T = int]':
<source>:13:10:   required from here
<source>:8:39: error: no matching function for call to
'MISC<int>::addVecVals<(&((MISC<int>*)this)->MISC<int>::vec1)>()'
    8 |     void add(void) { addVecVals<&vec1>();  }
      |                      ~~~~~~~~~~~~~~~~~^~
<source>:7:26: note: candidate: 'template<int* vc> void MISC<T>::addVecVals()
[with T* vc = vc; T = int]'
    7 |     template<T* vc> void addVecVals(){}
      |                          ^~~~~~~~~~
<source>:7:26: note:   template argument deduction/substitution failed:
<source>:8:34: error: '&((MISC<int>*)this)->MISC<int>::vec1' is not a valid
template argument of type 'int*' because '((MISC<int>*)this)->MISC<int>::vec1'
is not a variable
    8 |     void add(void) { addVecVals<&vec1>();  }
      |                                  ^~~~


But for C++98, C++11, C++14, we get:
<source>: In member function 'void MISC<T>::add()':
<source>:8:22: error: parse error in template argument list
    8 |     void add(void) { addVecVals<&vec1>();  }
      |                      ^~~~~~~~~~~~~~~~~

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

end of thread, other threads:[~2021-08-04  6:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-44906-4@http.gcc.gnu.org/bugzilla/>
2011-09-23 12:55 ` [Bug c++/44906] g++ is giving error: parse error in template argument list while using a c++ code paolo.carlini at oracle dot com
2011-09-23 14:11 ` manu at gcc dot gnu.org
2011-09-23 14:53 ` paolo.carlini at oracle dot com
2011-10-19 22:24 ` [Bug c++/44906] g++ is giving error: parse error in template argument list manu at gcc dot gnu.org
2021-08-04  6:20 ` 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).