Unwarranted warnings: decltype vs. NULL references

Unwarranted warnings: decltype vs. NULL references

Hello.
When building a project with /Wall (ICL 12.1.4.325), I get a number of warnings on the lines of

1>.h(303): warning #327: NULL reference is not allowed
1> -> std::enable_if< sizeof...( types ) != sizeof...( unpacked_types ), tuple< decltype( f( *( types * )nullptr ) )... > >::type

While normally I'd agree with this criticism, surely it has no point for an expression inside a decltype().

----
Best regards,
Vladimir

publicaciones de 6 / 0 nuevos
Último envío
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.

I'm having a hard time reproducing this...

sptxl8-302> cat ex.cpp

class types {};

template class C {};

template void f(T);

int main() {
C c;
return 0;
}
sptxl8-303> icpc -std=c++11 -Wall -c ex.cpp
sptxl8-304>

Can you please provide a reproducer?

thanks
Judy

Actually, I have found more spurious warnings/remarks.

#include 
class dereference {

public:

	template< typename ptr_type >

	auto operator () ( ptr_type &ptr ) -> decltype( *ptr ) const {

		return *ptr;

	}

};
template< typename fn_type, typename arg_type >

auto app( fn_type fn, arg_type arg ) -> decltype(fn(*(arg_type*)nullptr)) {

	return fn( arg );

}
template< typename... types >

void test3( types... values ) {

	printf( "%d%d%dn", values... );

}
int main() {

  int x = 123;

  app( dereference(), &x );

  test3( 1, 2, 3 );

  return 0;

}

Command line: icl /Qstd=c++0x /Wall tests.cpp
Bad warnings:

tests.cpp(6): warning #2536: type qualifiers are meaningless here
auto operator () ( ptr_type &ptr ) -> decltype( *ptr ) const {

tests.cpp(12): warning #327: NULL reference is not allowed
auto app( fn_type fn, arg_type arg ) -> decltype(fn(*(arg_type*)nullptr)) {

tests.cpp(17): remark #869: parameter "values" was never referenced
void test3( types... values ) {

The last remark shows up in the actual project in a different context as "warning #869". I'm not sure if there is a signficant difference.

Regards,
Vladimir

thank you... I can now reproduce the warnings and remark.

For the first warning, "type qualifiers are meaningless here" -- I believe that warningis valid.
You are declaring the late specified return type as int const (after it is instantiated) and it is meaningless. If you were trying to declare the operator() member function itself as const then the const keyword should have gone before the ->.

Anyway I will submit bug reports for the 327 warning and the 869 remark since those do look incorrect.

thanks again,
Judy

> For the first warning ...

Ah yes. Mea culpa. Although, shouldn't it also warn about "auto operator () ( ptr_type &ptr ) -> int const {" (with decltype() replaced by int) here? I guess I should have reported this one as a warning inconsistency.

Regards,
Vladimir

The "warning #327: NULL reference is not allowed" is now changed to "remark" in 13.0 update1.

Jennifer

Deje un comentario

Por favor inicie sesión para agregar un comentario. ¿No es socio? Únase ya