public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Paolo ZAMBOTTI <paolo.zambotti@st.com>
To: "cygwin@cygwin.com" <cygwin@cygwin.com>
Subject: cygwin x86_64: mingw64-g++ 6.4.0 (both i686 and x86_64) issue (bug?) with reinterpret_cast
Date: Mon, 23 Oct 2017 14:47:00 -0000	[thread overview]
Message-ID: <e53af017e2d84c40bb763073b4d3fd00@SFHDAG5NODE3.st.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1657 bytes --]

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.

[-- Attachment #2: test.cpp --]
[-- Type: text/plain, Size: 387 bytes --]

#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;

}

[-- Attachment #3: Type: text/plain, Size: 219 bytes --]


--
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

             reply	other threads:[~2017-10-23 14:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-23 14:47 Paolo ZAMBOTTI [this message]
2017-10-23 23:26 ` JonY
2017-10-24  9:19 ` Csaba Raduly
2017-10-31 10:01 Paolo ZAMBOTTI
2017-11-01 14:25 ` Csaba Raduly

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e53af017e2d84c40bb763073b4d3fd00@SFHDAG5NODE3.st.com \
    --to=paolo.zambotti@st.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).