public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/17207] New: No warning for nonsense template
@ 2004-08-27  7:30 igodard at pacbell dot net
  2004-08-27  7:34 ` [Bug c++/17207] " pinskia at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: igodard at pacbell dot net @ 2004-08-27  7:30 UTC (permalink / raw)
  To: gcc-bugs

struct D{};
template<typename T>
D& Foo(D& d) { return d;}
int main() {
    D d;
    Foo(d);
    return 0;
    }

gets you:

~/ootbc/common/test/src$ g++ foo1.cc
foo1.cc: In function `int main()':
foo1.cc:6: error: no matching function for call to `Foo(D&)'


which is dine - but if you take out the call then it compiles. As the function can *never* be called the declaration is nonsense and should be flagged at declaration.

Ivan

-- 
           Summary: No warning for nonsense template
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: igodard at pacbell dot net
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug c++/17207] No warning for nonsense template
  2004-08-27  7:30 [Bug c++/17207] New: No warning for nonsense template igodard at pacbell dot net
@ 2004-08-27  7:34 ` pinskia at gcc dot gnu dot org
  2004-08-27  7:56 ` igodard at pacbell dot net
  2004-08-27 13:15 ` bangerth at dealii dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-27  7:34 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-08-27 07:34 -------
This template is a very good template function really.
If you want to call it, use Foo<int> or someother type but I think we should not warn here at all.

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


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


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

* [Bug c++/17207] No warning for nonsense template
  2004-08-27  7:30 [Bug c++/17207] New: No warning for nonsense template igodard at pacbell dot net
  2004-08-27  7:34 ` [Bug c++/17207] " pinskia at gcc dot gnu dot org
@ 2004-08-27  7:56 ` igodard at pacbell dot net
  2004-08-27 13:15 ` bangerth at dealii dot org
  2 siblings, 0 replies; 4+ messages in thread
From: igodard at pacbell dot net @ 2004-08-27  7:56 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From igodard at pacbell dot net  2004-08-27 07:56 -------
Yes, you can call it with an explicit argument. But a template that never uses one of its template arguments makes no sense to me, and most likely reflects an error whether it's syntactically correct or not, yes?

Ivan

-- 


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


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

* [Bug c++/17207] No warning for nonsense template
  2004-08-27  7:30 [Bug c++/17207] New: No warning for nonsense template igodard at pacbell dot net
  2004-08-27  7:34 ` [Bug c++/17207] " pinskia at gcc dot gnu dot org
  2004-08-27  7:56 ` igodard at pacbell dot net
@ 2004-08-27 13:15 ` bangerth at dealii dot org
  2 siblings, 0 replies; 4+ messages in thread
From: bangerth at dealii dot org @ 2004-08-27 13:15 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-08-27 13:15 -------
I can think of a number of good reasons to use templates that don't 
use their argument. For example, they may have static variables 
in them and you may want to use one or the other one. libstdc++ 
uses something like this for the allocator classes. A warning 
would certainly be very unwelcome to many. 
 
W. 

-- 


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


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

end of thread, other threads:[~2004-08-27 13:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-27  7:30 [Bug c++/17207] New: No warning for nonsense template igodard at pacbell dot net
2004-08-27  7:34 ` [Bug c++/17207] " pinskia at gcc dot gnu dot org
2004-08-27  7:56 ` igodard at pacbell dot net
2004-08-27 13:15 ` bangerth at dealii dot 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).