Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NEON intrinsic types work in C but throw invalid arguments error in C++

I have problems with using NEON intrinsics and inline assembly in Android NDK.

NEON types like float32x4_t give an "invalid arguments" error when compiling C++ code with GCC 4.6 and 4.8, however, the code compiles fine if compiled as C.

For example, here's some code:

inline float32x4_t VectorAdd(float32x4_t a, float32x4_t b)
{
  return vaddq_f32(a, b);
}

I get two errors here:

  • In the function itself: Invalid arguments ' Candidates are: ? vaddq_f32(?, ?) '.
  • Where the function is called: Invalid arguments ' Candidates are: ? VectorAdd(?, ?) '.

All NEON types are displayed as ? in the error message, while non-NEON types are displayed correctly.

What is also strange is that functions which only use NEON types as return values (for example, vld1q_f32 and my abstract wrapper of it) don't suffer from the error.

I tried the same code in GCC Explorer 4.6 and 4.5, and there is no error, and correct and optimized assembly is generated, however, it doesn't work with Android NDK.

like image 354
Triang3l Avatar asked Aug 27 '13 18:08

Triang3l


1 Answers

As a workaround, in Window / Preferences / C/C++ / Code Analysis, set the Severity of "Invalid Arguments" errors to Warning, so that these bogus errors won't prevent launching the application.

like image 95
r6144 Avatar answered Nov 05 '22 13:11

r6144