public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ldionne.2 at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/67376] New: Comparison with pointer to past-the-end of array fails inside constant expression
Date: Thu, 27 Aug 2015 23:00:00 -0000 [thread overview]
Message-ID: <bug-67376-4@http.gcc.gnu.org/bugzilla/> (raw)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67376
Bug ID: 67376
Summary: Comparison with pointer to past-the-end of array fails
inside constant expression
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ldionne.2 at gmail dot com
Target Milestone: ---
The following code fails to compile on GCC trunk:
struct array {
int elems_[1];
};
constexpr array a{{0}};
static_assert(a.elems_ != a.elems_ + 1, "");
The error (formatted to fit the report) is
[snip]: error: non-constant condition for static assertion
static_assert(a.elems_ != a.elems_ + 1, "");
^
[snip]: error: ‘(((const int*)(& a.array::elems_)) !=
(((const int*)(& a.array::elems_)) + 4u))’
is not a constant expression
static_assert(a.elems_ != a.elems_ + 1, "");
^
It seems like GCC does not like the fact that we're comparing a past-the-end
pointer. But then again, that's weird because the following code works fine:
constexpr int a[1] = {0};
static_assert(a != a + 1, "");
Live example: http://melpon.org/wandbox/permlink/4QKMVN5vm3ePJcpY
>From gcc-bugs-return-495764-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Aug 27 23:05:40 2015
Return-Path: <gcc-bugs-return-495764-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 67221 invoked by alias); 27 Aug 2015 23:05:39 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 67119 invoked by uid 48); 27 Aug 2015 23:05:36 -0000
From: "juergen.reuter at desy dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/67377] New: gcc 6.0 fails to compile on Darwin 14
Date: Thu, 27 Aug 2015 23:05:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c
X-Bugzilla-Version: 6.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: juergen.reuter at desy dot de
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone
Message-ID: <bug-67377-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-08/txt/msg01906.txt.bz2
Content-length: 3803
https://gcc.gnu.org/bugzilla/show_bug.cgi?idg377
Bug ID: 67377
Summary: gcc 6.0 fails to compile on Darwin 14
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: juergen.reuter at desy dot de
Target Milestone: ---
When compiling gcc (svn r227279) on Darwin 14.5.0 with Xcode 6.4, clang Apple
LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.5.0, I get the compile error:
test -f config.h || (rm -f stamp-h1 &&
/Applications/Xcode.app/Contents/Developer/usr/bin/make stamp-h1)
true "AR_FLAGS=rc" "CC_FOR_BUILD=gcc" "CFLAGS=-g " "CXXFLAGS=-g "
"CFLAGS_FOR_BUILD=-g -O2" "CFLAGS_FOR_TARGET=-g -O2"
"INSTALL=/opt/local/bin/ginstall -c" "INSTALL_DATA=/opt/local/bin/ginstall -c
-m 644" "INSTALL_PROGRAM=/opt/local/bin/ginstall -c"
"INSTALL_SCRIPT=/opt/local/bin/ginstall -c" "LDFLAGS=-Wl,-no_pie "
"LIBCFLAGS=-g -O2" "LIBCFLAGS_FOR_TARGET=-g -O2"
"MAKE=/Applications/Xcode.app/Contents/Developer/usr/bin/make"
"MAKEINFO=makeinfo --split-sizeP00000 --split-sizeP00000
--split-sizeP00000 " "PICFLAG=" "PICFLAG_FOR_TARGET=" "SHELL=/bin/sh"
"EXPECT=expect" "RUNTEST=runtest" "RUNTESTFLAGS=" "exec_prefix=/usr/local"
"infodir=/usr/local/share/info" "libdir=/usr/local/lib" "prefix=/usr/local"
"tooldir=/usr/local/x86_64-apple-darwin14.5.0" "AR=ar" "AS=as" "CC=gcc"
"CXX=g++ -std=gnu++98"
"LD=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld"
"LIBCFLAGS=-g -O2" "NM=nm" "PICFLAG=" "RANLIB=ranlib" "DESTDIR=" DO=all
multi-do # /Applications/Xcode.app/Contents/Developer/usr/bin/make
/Applications/Xcode.app/Contents/Developer/usr/bin/make all-am
true DO=all multi-do # /Applications/Xcode.app/Contents/Developer/usr/bin/make
test -f config.h || (rm -f stamp-h1 &&
/Applications/Xcode.app/Contents/Developer/usr/bin/make stamp-h1)
make[3]: Nothing to be done for `all'.
g++ -std=gnu++98 -fno-PIE -c -DTARGET_NAME=\"x86_64-apple-darwin14.5.0\" -g
-DIN_GCC -fno-strict-aliasing -fno-exceptions -fno-rtti
-fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings
-Wcast-qual -Wno-format -Wmissing-format-attribute -Woverloaded-virtual
-pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings
-fno-common -DHAVE_CONFIG_H -I. -I. -I../../gcc -I../../gcc/.
-I../../gcc/../include -I./../intl -I../../gcc/../libcpp/include
-I/usr/local//include -I/usr/local//include -I/usr/local//include
-I../../gcc/../libdecnumber -I../../gcc/../libdecnumber/dpd -I../libdecnumber
-I../../gcc/../libbacktrace -o toplev.o -MT toplev.o -MMD -MP -MF
./.deps/toplev.TPo ../../gcc/toplev.c
clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is
deprecated
[....]
../../gcc/toplev.c:1320:10: error: use of undeclared identifier
'flag_loop_block'
|| flag_loop_block
^
../../gcc/toplev.c:1321:10: error: use of undeclared identifier
'flag_loop_interchange'
|| flag_loop_interchange
^
../../gcc/toplev.c:1322:10: error: use of undeclared identifier
'flag_loop_strip_mine'
|| flag_loop_strip_mine
^
This has probably to do with changes from Yosemite 10.10.4->10.10.5, or with
Xcode 6.4 (quite unlikely) or any changes in gcc between r226713 and r227279.
When using r276713, toplevel.c compiles but then I'm stuck with:
The directory that should contain system headers does not exist:
/usr/include
What puzzles me is that MAC OS X/clang tries to compile the C code in gcc by
means of g++ -std=gnu++98 and then issuing a warning that this behavior is
deprecated. I'll do a few check, but someone else should have been stumbled
over those things, too.
next reply other threads:[~2015-08-27 23:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-27 23:00 ldionne.2 at gmail dot com [this message]
2015-08-29 15:49 ` [Bug c++/67376] " trippels at gcc dot gnu.org
2015-09-04 14:07 ` trippels at gcc dot gnu.org
2015-09-04 14:24 ` trippels at gcc dot gnu.org
2015-09-04 15:06 ` [Bug c++/67376] [5/6 regression] " trippels at gcc dot gnu.org
2015-09-04 15:27 ` trippels at gcc dot gnu.org
2015-09-04 15:30 ` msebor at gcc dot gnu.org
2015-10-16 8:27 ` rguenth at gcc dot gnu.org
2016-04-02 17:15 ` msebor at gcc dot gnu.org
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=bug-67376-4@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/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).