X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type:content-transfer-encoding; q=dns; s=default; b=SRhuKiUp2FQkgHyjnu5RYLAKDW0+bqI3CgNC2PAY+jH 8PzheGVZr7B9f86hrO5gnmCopd9yY+LDfAMJhxxgvujAmAhfXibfoXh4Eawhv5HR WhffKZFF9m7ISrqGXRsQYrCFHQ1JfiIIQ1GbQOODQ4D3B+zn47st71M/rgh/jDqU = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type:content-transfer-encoding; s=default; bh=8JHMEQcr3MRO6+uJDsPWUwxy7BQ=; b=kqaJGcarUuw3cnKeo cJ8HbwV/zMb6z9WwnM6Lz0E4maV3w9Z5O+24NUUAshpfXxOZW2qXFFYHhJYyncE4 +DgUVZfKL6WvDAm7AfvgOUw9GW53wum4ZdeKF4dcSxzgk9V6ymxisri9CNcJ6sHf 9pLE/X2r4Y4UDmHd6jCSCUYRmo= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=no version=3.3.2 spammy=tao, Tao, boots, picky X-HELO: mail-qt0-f177.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-transfer-encoding; bh=FwyK1X0RG34PzGxOuQ+BOmEVgGgyr8nlGn4V78OmLtU=; b=W2Yw571kTVP4Nz0mU2cjpbDyc0hxt/y337aeU9tZvEWyE5H2jd0bV/AmiyTnCgIS0Y YPWIhkdwpM/Ho3vhPLYCOrkPao/zzIqFMTNgC+Iulxy71drevr2qHjV9GUQp430TsALl ZEpUVBwbnE6CvPM84GSj6ecsGDmVqxDxigxFEas8FcD1uSoOSBtmDItampbe9cIlbLUB nI27oWzKQvhxPjoijZBYqY1tFao9lZI/xvT/6MTpXszoZQqYypDaShRydCH7azvnX2Jt gwLLD2pDB6o19bpaWHIoALFVtUreuBxb6MMTZg9SY6q3KJOJOAyBefHuglYTLM90wIAg OxEg== X-Gm-Message-State: AMCzsaVKSy9M32sM1lYTfEHaj7HiRpPo/0+a89tZRWnM0WMvmf4lpyaE sa9y3rpRJq+TpZ62kjHxs6r5RLHLzVY8NCtBjUmfnQ== X-Google-Smtp-Source: ABhQp+ThrzOszHWLPVot4r5aR3bo6CFnf/p5sS42ydQjBqqJ7WObsmyljujqGlHvF1F2759NLo7gpoJ95kysU7hDuaQ= X-Received: by 10.200.15.136 with SMTP id b8mr24672161qtk.64.1508836759087; Tue, 24 Oct 2017 02:19:19 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: From: Csaba Raduly Date: Tue, 24 Oct 2017 11:19:18 +0200 Message-ID: Subject: Re: cygwin x86_64: mingw64-g++ 6.4.0 (both i686 and x86_64) issue (bug?) with reinterpret_cast To: cygwin list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id v9O9JgjA028248 Hi Paolo, On Mon, Oct 23, 2017 at 4:47 PM, Paolo ZAMBOTTI wrote: > 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) ... Note that compilers tend to become more picky with time. The fact that this code was compiling fine with GCC 5.4 may well be a bug in GCC 5.4 $ gcc-630 -std=gnu++11 -c -Wall -pedantic -Wextra fail.cpp fail.cpp: In function ‘int main(int, char**)’: fail.cpp:10:34: error: reinterpret_cast from integer to pointer static constexpr void* test1 = (void*)(-1LL); ^~~~~~~~~~~~~ fail.cpp:11:34: error: reinterpret_cast from integer to pointer static constexpr void* test2 = (void*)(-1L); ^~~~~~~~~~~~ $ gcc-7 -std=gnu++11 -c -Wall -pedantic -Wextra fail.cpp gcc-7 gcc-710 csabaraduly AT HU-GD-36813:/tmp $ gcc-7 -std=gnu++11 -c -Wall -pedantic -Wextra fail.cpp fail.cpp: In function ‘int main(int, char**)’: fail.cpp:10:34: error: ‘reinterpret_cast(-1)’ is not a constant expression static constexpr void* test1 = (void*)(-1LL); ^~~~~~~~~~~~~ fail.cpp:11:34: error: ‘reinterpret_cast(-1)’ is not a constant expression static constexpr void* test2 = (void*)(-1L); ^~~~~~~~~~~~ $ gcc-8 -std=gnu++11 -c -Wall -pedantic -Wextra fail.cpp fail.cpp: In function ‘int main(int, char**)’: fail.cpp:10:34: error: reinterpret_cast from integer to pointer static constexpr void* test1 = (void*)(-1LL); ^~~~~~~~~~~~~ fail.cpp:11:34: error: reinterpret_cast from integer to pointer static constexpr void* test2 = (void*)(-1L); ^~~~~~~~~~~~ $ clang++ -std=gnu++11 -c -Wall -pedantic -Wextra fail.cpp fail.cpp:10:26: error: constexpr variable 'test1' must be initialized by a constant expression static constexpr void* test1 = (void*)(-1LL); ^ ~~~~~~~~~~~~~ fail.cpp:10:34: note: cast that performs the conversions of a reinterpret_cast is not allowed in a constant expression static constexpr void* test1 = (void*)(-1LL); ^ fail.cpp:11:26: error: constexpr variable 'test2' must be initialized by a constant expression static constexpr void* test2 = (void*)(-1L); ^ ~~~~~~~~~~~~ fail.cpp:11:34: note: cast that performs the conversions of a reinterpret_cast is not allowed in a constant expression static constexpr void* test2 = (void*)(-1L); ^ I think clang explains it best. Note: these were Linux compilers, but your question is not Cygwin-specific (and including windows.h is unnecessary). Csaba -- GCS a+ e++ d- C++ ULS$ L+$ !E- W++ P+++$ w++$ tv+ b++ DI D++ 5++ The Tao of math: The numbers you can count are not the real numbers. Life is complex, with real and imaginary parts. "Ok, it boots. Which means it must be bug-free and perfect. " -- Linus Torvalds "People disagree with me. I just ignore them." -- Linus Torvalds -- 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