public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "lucdanton at free dot fr" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/59329] Using `assert(...)` is not allowed in constexpr functions
Date: Thu, 23 Jan 2014 17:13:00 -0000	[thread overview]
Message-ID: <bug-59329-4-CS7M4bm5gI@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-59329-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59329

lucdanton at free dot fr changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lucdanton at free dot fr

--- Comment #2 from lucdanton at free dot fr ---
As a workaround I thought about (ab)using the comma operator:

    return assert( cond ), expr;

The reasoning being that C guarantees that assert(…) is a void expression
(regardless of NDEBUG). This is rejected as well, although I’m not entirely
sure why. After a quick look at the preprocessed source, it appears GCC rejects
(‘body not a return statement’, again) functions of the form:

//------

void some_extern_func();

constexpr int foo(int i)
{ return (true ? static_cast<void>(0) : some_extern_func()), i; }

//-----

If the third leg of the conditional operator is e.g. throw whatever (a common
trick to ‘halt’ CTFE) everything behaves as expected.

Does this warrant opening another bug?
>From gcc-bugs-return-441337-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Jan 23 17:18:12 2014
Return-Path: <gcc-bugs-return-441337-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 7164 invoked by alias); 23 Jan 2014 17:18:11 -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 6869 invoked by uid 55); 23 Jan 2014 17:17:39 -0000
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/59872] [4.9 Regression] Cannot move std::map with move-only mapped_type
Date: Thu, 23 Jan 2014 17:18:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: libstdc++
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: redi at gcc dot gnu.org
X-Bugzilla-Status: ASSIGNED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: redi at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 4.9.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-59872-4-VRdh7SJyvN@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-59872-4@http.gcc.gnu.org/bugzilla/>
References: <bug-59872-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: 2014-01/txt/msg02479.txt.bz2
Content-length: 1368

http://gcc.gnu.org/bugzilla/show_bug.cgi?idY872

--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Author: redi
Date: Thu Jan 23 17:17:04 2014
New Revision: 206994

URL: http://gcc.gnu.org/viewcvs?rev 6994&root=gcc&view=rev
Log:
    PR libstdc++/59872
    * include/bits/stl_map.h (map::operator=(map&&)): Fix comment.
    * include/bits/stl_multimap.h (multimap::operator=(multimap&&)):
    Likewise.
    * include/bits/stl_multiset.h (multiset::operator=(multiset&&)):
    Likewise.
    * include/bits/stl_set.h (set::operator=(set&&)): Likewise.
    * include/bits/stl_tree.h (_Rb_tree::_M_move_data): New overloaded
    functions to perform moving or copying of elements from rvalue tree.
    (_Rb_tree::_Rb_tree(_Rb_tree&&)): Use _M_move_data.
    (_Rb_tree::_Rb_tree(_Rb_tree&&, _Node_allocator&&)): Likewise.
    * testsuite/23_containers/map/59872.cc: New.
    * testsuite/23_containers/map/56613.cc: Remove duplicate include.

Added:
    trunk/libstdc++-v3/testsuite/23_containers/map/59872.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/bits/stl_map.h
    trunk/libstdc++-v3/include/bits/stl_multimap.h
    trunk/libstdc++-v3/include/bits/stl_multiset.h
    trunk/libstdc++-v3/include/bits/stl_set.h
    trunk/libstdc++-v3/include/bits/stl_tree.h
    trunk/libstdc++-v3/testsuite/23_containers/map/56613.cc


  parent reply	other threads:[~2014-01-23 17:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-28 11:17 [Bug c++/59329] New: " vittorio.romeo at outlook dot com
2013-12-02 14:04 ` [Bug c++/59329] " daniel.kruegler at googlemail dot com
2014-01-23 17:13 ` lucdanton at free dot fr [this message]
2014-05-08 21:18 ` jason at gcc dot gnu.org
2015-03-27 17:36 ` paolo.carlini at oracle dot com
2015-03-27 17:40 ` paolo at gcc dot gnu.org
2015-03-27 17:41 ` paolo.carlini at oracle dot com

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-59329-4-CS7M4bm5gI@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).