Quantcast
Channel: Intel® Software - Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1175

icc 17.0.0 rejects valid C++ code with variable argument function

$
0
0

Compiler version and platform: 

Intel(R) C Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 17.0.0.098 Build 20160721

The latest clang also incorrectly rejects the code. 

$ g++-6.2 -Wall -Wextra -pedantic -std=c++14 small.cpp
$
$ icc -std=c++14 small.cpp
small.cpp(12): error: a non-POD (Plain Old Data) class type cannot be fetched by va_arg
    A v = va_arg (a, A);
          ^

small.cpp(19): warning #1595: non-POD (Plain Old Data) class type passed through ellipsis
    foo (t, t);
            ^

compilation aborted for small.cpp (code 2)
$
$ cat small.cpp
#include <cstdarg>

struct A
{
  virtual ~A () {}
};

void foo (A p, ...)
{
  va_list a;
  va_start (a, p);
  A v = va_arg (a, A);
  va_end (a);
}

int main ()
{
  A t;
  foo (t, t);
  return 0;
}
$

 


Viewing all articles
Browse latest Browse all 1175

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>