A pointless pointless warning

A pointless pointless warning

Hello.This (ICL,/Wall):

template< unsigned threshold > bool fn( unsigned n ) { return n >= threshold; } int main() { fn< 1 >( 123 ); // ok fn< 0 >( 123 ); // warning #186: pointless comparison of unsigned integer with zero return 0; } 
Is the compiler suggesting that a separate specialization is needed for threshold==0? I think template arguments should be treated more like function arguments with regard to raising this diagnostic message, and less like literals.On another note, I'm still wondering about a minor point from one of my previous posts which was left uncommented probably due to not being stated clear enough. Here, of all the functions, only f1 gets "warning #2536: type qualifiers are meaningless here". It looks like there is some inconsistency regarding this warning.
#include template< typename ptype > auto f1( ptype ptr ) -> decltype( *ptr ) const { return *ptr; } template< typename ptype > auto f2( ptype ptr ) -> int const { return *ptr; } template< typename ptype > std::remove_pointer< ptype >::type const f3( ptype ptr ) { return *ptr; } template< typename ptype > int const f4( ptype ptr ) { return *ptr; } int const f9( int *ptr ) { return *ptr; } void test() { int x = 123; f1( &x ); f2( &x ); f3( &x ); f4( &x ); f9( &x ); } 
----Best regards,Vladimir

5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

I had a similar problem with the Warning 186 some time ago. Please take a look at a thread:


There is something wrongwithanalysis of 'unsigned int' variables by Intel C++ compiler in your and my cases.

Best regards,

With regards to the second issue (the lack of warning for late specified return types):

(1) On Windows you will see a diagnostic for f4() and f9() if you add the following command line option:

!% icl -c /Qdiag-warning:858 f2.cpp
Intel C++ Compiler XE for applications running on IA-32, Version Mainline Bet
a Build x
Built Jun 9 2012 20:04:48 by jward4 on JWARD4-DESK in D:/workspaces/cfe/dev
Copyright (C) 1985-2012 Intel Corporation. All rights reserved.

f2.cpp(19): warning #858: type qualifier on return type is meaningless
int const f4( ptype ptr ) {

f2.cpp(23): warning #858: type qualifier on return type is meaningless
int const f9( int *ptr ) {

f2.cpp(4): warning #2536: type qualifiers are meaningless here
auto f1( ptype ptr ) -> decltype( *ptr ) const {
detected during instantiation of "f1" based on template argument *> at line 29

Diagnostic 858 is only a remark by default on Windows which is why you need to
explicitenable it to see it.We should probably do the same (downgrade the diag to a remark)
with diagnostic 2536 since we have lots of complaints about our Windows compiler issuing more
warnings than Microsoft's. I have entered DPD200232951 for us to do that.

(2) It does look like there is still an inconsistency in that we don't give a diagnostic for f2().
I have entered that into our bug tracking database as DPD200232950. Thank you for reporting it.


For the first case, while I think the warning is validly applied since as a template instantiation, the compiler does really view it as a numeric literal comparison, I do think your point on the usefulness of it is valid, so I've submitted a feature request to look into disabling it in this context.

Hi to everyone on the thread.

The issue Judy entered about diagnostic 2536 should not be emitted under /Wall is resolved in our Composer XE 2013 compiler.  You need to specify /W5 (our Intel compiler-specific highest diagnostic level) to enable it.  The other issues/requests are still being worked.

Leave a Comment

Please sign in to add a comment. Not a member? Join today