public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/58848] New: constexpr function allows throw
@ 2013-10-22 19:48 mib.bugzilla at gmail dot com
  2013-10-23  9:05 ` [Bug c++/58848] " daniel.kruegler at googlemail dot com
  2013-10-30 14:58 ` redi at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: mib.bugzilla at gmail dot com @ 2013-10-22 19:48 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 3920 bytes --]

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

            Bug ID: 58848
           Summary: constexpr function allows throw
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mib.bugzilla at gmail dot com

Created attachment 31072
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31072&action=edit
should get compilation error

A simple test case rejects throw inside constexpr function, but a more
complicated test case allows the throw.  Attaching 2 test cases

Bad:

 g++ constexp_error.cpp -std=c++0x
-bash-4.1$ ./a.out
fail, exception raised

Good:
 g++ constexp_ok.cpp -std=c++0x
constexp_ok.cpp: In function âint main()â:
constexp_ok.cpp:15:47:   in constexpr expansion of
âfum<DUMMY>::numSubEntities<int>(5)â
constexp_ok.cpp:8:73: error: expression â<throw-expression>â is not a
constant-expression
        throw std::out_of_range("a point has only subentities of codim=0");

gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/rdrive/ref/gcc/4.8.1/rhel60/efi2/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.8.1/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with:
/rusers/sys_cron/grab_gcc/downloads_rel/4.8.1/gcc-4.8.1/configure
--prefix=/rdrive/ref/gcc/4.8.1/rhel60/efi2
--enable-languages=c,c++,objc,fortran --disable-multilib --enable-bootstrap
--target=x86_64-unknown-linux-gnu --disable-bootstrap --enable-decimal-float
--with-gmp=/rusers/sys_cron/grab_gcc/downloads_rel/lib/efi2
--with-mpfr=/rusers/sys_cron/grab_gcc/downloads_rel/lib/efi2
--with-mpc=/rusers/sys_cron/grab_gcc/downloads_rel/lib/efi2
Thread model: posix
gcc version 4.8.1 (GCC)
>From gcc-bugs-return-432488-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Oct 22 19:50:07 2013
Return-Path: <gcc-bugs-return-432488-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 22769 invoked by alias); 22 Oct 2013 19:50:07 -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 22719 invoked by uid 48); 22 Oct 2013 19:50:03 -0000
From: "mib.bugzilla at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/58848] constexpr function allows throw
Date: Tue, 22 Oct 2013 19:50:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: unknown
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: mib.bugzilla at gmail dot com
X-Bugzilla-Status: UNCONFIRMED
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: attachments.created
Message-ID: <bug-58848-4-IknhsjYzNA@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-58848-4@http.gcc.gnu.org/bugzilla/>
References: <bug-58848-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: 2013-10/txt/msg01632.txt.bz2
Content-length: 319

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

--- Comment #1 from mib.bugzilla at gmail dot com ---
Created attachment 31073
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id1073&actioníit
simpler test case gets compilation error (good)

both test cases should get a compilation error because of the throw.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/58848] constexpr function allows throw
  2013-10-22 19:48 [Bug c++/58848] New: constexpr function allows throw mib.bugzilla at gmail dot com
@ 2013-10-23  9:05 ` daniel.kruegler at googlemail dot com
  2013-10-30 14:58 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2013-10-23  9:05 UTC (permalink / raw)
  To: gcc-bugs

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

Daniel Krügler <daniel.kruegler at googlemail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |daniel.kruegler@googlemail.
                   |                            |com

--- Comment #2 from Daniel Krügler <daniel.kruegler at googlemail dot com> ---
I cannot follow your argumentation for constexp_error.cpp: The main function
invokes

ReferenceElement<RefElType::POINT>::numSubEntities(7)

This function is declared as

  static inline unsigned numSubEntities(int codim) {
    return typeTraits_<RefElType::POINT>::numSubEntities(codim);
  }

Note in particular that this is *not* a constexpr function. Now it delegates to
typeTraits_<RefElType::POINT>::numSubEntities, which is defined as:

  static constexpr unsigned numSubEntities(int codim) {
    return codim==0 ? 11 : throw 20;
  }

This is a constexpr function, but it is not called with constant arguments that
require the evaluation of this function in a constexpr context. Thus, throwing
an exception is valid here.

So what is the problem?
>From gcc-bugs-return-432525-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Wed Oct 23 09:21:26 2013
Return-Path: <gcc-bugs-return-432525-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 2030 invoked by alias); 23 Oct 2013 09:21:25 -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 1963 invoked by uid 48); 23 Oct 2013 09:21:19 -0000
From: "schwab@linux-m68k.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug testsuite/58851] New: FAIL: gfortran.dg/unlimited_polymorphic_13.f90  -O0  execution test
Date: Wed, 23 Oct 2013 09:21:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: testsuite
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: schwab@linux-m68k.org
X-Bugzilla-Status: UNCONFIRMED
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 blocked cf_gcctarget
Message-ID: <bug-58851-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: 2013-10/txt/msg01669.txt.bz2
Content-length: 597

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

            Bug ID: 58851
           Summary: FAIL: gfortran.dg/unlimited_polymorphic_13.f90  -O0
                    execution test
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: testsuite
          Assignee: unassigned at gcc dot gnu.org
          Reporter: schwab@linux-m68k.org
            Blocks: 58793
            Target: i386-*-*, m68k-*-*

The storage size of real(kind\x10) is target-dependent.  On i386 and m68k it is
96, not 128.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/58848] constexpr function allows throw
  2013-10-22 19:48 [Bug c++/58848] New: constexpr function allows throw mib.bugzilla at gmail dot com
  2013-10-23  9:05 ` [Bug c++/58848] " daniel.kruegler at googlemail dot com
@ 2013-10-30 14:58 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2013-10-30 14:58 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The initializer for ReferenceElement<RefElType::POINT>::v calls the function in
a constant expression, but G++ doesn't diagnose it unless you instantiate that
member.

You get an error if you do:

int main() {
  return ReferenceElement<RefElType::POINT>::v;
}


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-10-30 14:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-22 19:48 [Bug c++/58848] New: constexpr function allows throw mib.bugzilla at gmail dot com
2013-10-23  9:05 ` [Bug c++/58848] " daniel.kruegler at googlemail dot com
2013-10-30 14:58 ` redi at gcc dot gnu.org

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