Web lists-archives.com

cygwin x86_64: mingw64-g++ 6.4.0 (both i686 and x86_64) issue (bug?) with reinterpret_cast




Hello,

I'm having some issues while compiling C++ code with mingw64 c++ compiler (6.4.0) distributed within Cygwin packages.
I can guess the issue I'm going to report is not strictly related to Cygwin distribution but I cannot test other mingw64 distributions so let me start reporting the issue here...
Once said that, I'm open to any suggestions for better reporting place...

I'm not an expert in C and even less in C++ so I hope to not generate stupid noise... but the same code was compiling fine with previous version (5.4) ...

The attached file is the simplest example that triggers the issue.

If I try to compile with "x86_64-w64-mingw32-gcc -o test.exe test.cpp" the output is the following

test.cpp: In function 'int main(int, char**)':
test.cpp:7:34: error: reinterpret_cast from integer to pointer
   static constexpr void* test2 = (void*)(-1LL);
                                  ^~~~~~~~~~~~~

While, if I try to compile with "i686-w64-mingw32-gcc -o test.exe test.cpp" the output is the following

test.cpp: In function 'int main(int, char**)':
test.cpp:12:34: error: reinterpret_cast from integer to pointer
   static constexpr void* test2 = (void*)(-1L);
                                  ^~~~~~~~~~~~

The test is effectively build to always fail but the current behavior is exactly the opposite of what I was expecting:
x86_64 complains with (-1LL) cast while I was expecting it to fail on (-1L)
i686 complains with (-1L) cast while I was expecting it to fail on (-1LL)


Just to complete the picture, my environment is:
Windows 7 machine
Latest Cygwin (updated today 23 -Oct-2017)

Regards,
Paolo.
#include <windows.h>
#include <stdio.h>

int main (int argc, char **argv) {
#ifdef _WIN64 
  static constexpr void* test1 = (void*)(-1L);
  static constexpr void* test2 = (void*)(-1LL);

  printf("%llx, %llx\n", test1, test2);
#else
  static constexpr void* test1 = (void*)(-1LL);
  static constexpr void* test2 = (void*)(-1L);

  printf("%lx, %lx\n", test1, test2);
#endif

return 0;

}
--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple