Bug 15723 - Over-eager warning not appropriate in templates
Summary: Over-eager warning not appropriate in templates
Status: RESOLVED DUPLICATE of bug 11856
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.0
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-05-29 11:54 UTC by Ivan Godard
Modified: 2004-05-29 14:49 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2004-05-29 12:33:34


Attachments
Compiler output (-v -save-temps) (907 bytes, text/plain)
2004-05-29 11:55 UTC, Ivan Godard
Details
Source code (-save-temps) (104.42 KB, text/plain)
2004-05-29 11:56 UTC, Ivan Godard
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ivan Godard 2004-05-29 11:54:50 UTC
The warning (line 960) tries to catch non-sensical arithmetic typing and is generally a useful catcher of bugs. However in template contexts, tests in the code must deal with a variety of types, for some of which the test is determined (and so causes the warning) and for others of which it does useful FOC. In general, this warning should not be issued when the type in question is a tependent of a template argument, and should be issued in all other contexts.

Ivan
Comment 1 Ivan Godard 2004-05-29 11:55:29 UTC
Created attachment 6427 [details]
Compiler output (-v -save-temps)
Comment 2 Ivan Godard 2004-05-29 11:56:35 UTC
Created attachment 6428 [details]
Source code (-save-temps)
Comment 3 Ivan Godard 2004-05-29 12:18:39 UTC
p.s. I tried without success to reproduce this warning in a simple template case e.g.:
#include    <iostream>
template<typename T>
void Foo(T t) { if (t < 0) std::cout << "foo" << std::endl; }
int main() {
    int i; unsigned int ui;
    Foo(i);
    Foo(ui);
    return 0;
    }


This suggests that the compiler already omits this warning for templates, and I have hit a bug (rather than a missing feature) in which it is still warning in the case I happened to hit.

Ivan
Comment 4 Andrew Pinski 2004-05-29 12:33:32 UTC
Confirmed with your example with -Wextra (aka -W).  Note some warnings are from differnet places 
and are controlled differently.  I forgot why this warns with -W and your complete example warns with 
-Wall.

PS I think there is a bug like this some where also.
Comment 5 Andrew Pinski 2004-05-29 14:49:17 UTC
Yes this is a dup of bug 11856.

*** This bug has been marked as a duplicate of 11856 ***