public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/57941] New: [c++11] confusing error message with invalid constexpr constructor in template struct
@ 2013-07-20 17:41 f.heckenbach@fh-soft.de
2013-07-20 20:54 ` [Bug c++/57941] " manu at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: f.heckenbach@fh-soft.de @ 2013-07-20 17:41 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57941
Bug ID: 57941
Summary: [c++11] confusing error message with invalid constexpr
constructor in template struct
Product: gcc
Version: 4.7.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: f.heckenbach@fh-soft.de
% cat test.cpp
template <typename T> struct a
{
int i;
constexpr a (): i (b ()) { }
constexpr int b () { return c (); }
int c () const { throw 42; }
constexpr operator bool () { return true; }
};
static_assert (a <int> (), "foo");
%g++-4.7 -std=c++11 test.cpp
test.cpp:10:1: error: non-constant condition for static assertion
test.cpp:10:1: error: 'constexpr a<T>::a() [with T = int]' called in a constant
expression
test.cpp:4:13: note: 'constexpr a<T>::a() [with T = int]' is not usable as a
constexpr function because:
%
Because what?
This message is particularly confusing if other unrelated messages appear
afterwards, as it wrongly claims those to be the reason for this one.
(I understand that the program is wrong, it's just about the message.)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/57941] [c++11] confusing error message with invalid constexpr constructor in template struct
2013-07-20 17:41 [Bug c++/57941] New: [c++11] confusing error message with invalid constexpr constructor in template struct f.heckenbach@fh-soft.de
@ 2013-07-20 20:54 ` manu at gcc dot gnu.org
2014-11-03 10:31 ` paolo.carlini at oracle dot com
2014-11-18 3:44 ` jason at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: manu at gcc dot gnu.org @ 2013-07-20 20:54 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: 6775 bytes --]
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57941
Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2013-07-20
CC| |manu at gcc dot gnu.org
Ever confirmed|0 |1
Known to fail| |4.8.0, 4.9.0
--- Comment #1 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
Confirmed. It also fails on trunk.
Clang++:
test.cc:10:16: error: static_assert expression is not an integral constant
expression
static_assert (a <int> (), "foo");
^~~~~~~~~~
test.cc:5:31: note: non-constexpr function 'c' cannot be used in a constant
expression
constexpr int b () { return c (); }
^
test.cc:4:22: note: in call to ')'
constexpr a (): i (b ()) { }
^
test.cc:10:16: note: in call to 'a()'
static_assert (a <int> (), "foo");
^
test.cc:6:7: note: declared here
int c () const { throw 42; }
^
1 error generated.
which is not perfect but it is clearly better.
The code that handles this is at explain_invalid_constexpr_fn at
/home/manuel/test1/src/gcc/cp/semantics.c:6461
save_loc = input_location;
input_location = DECL_SOURCE_LOCATION (fun);
inform (0, "%q+D is not usable as a constexpr function because:", fun);
/* First check the declaration. */
if (is_valid_constexpr_fn (fun, true))
{
/* Then if it's OK, the body. */
if (DECL_DEFAULTED_FN (fun))
explain_implicit_non_constexpr (fun);
else
{
body = massage_constexpr_body (fun, DECL_SAVED_TREE (fun));
require_potential_rvalue_constant_expression (body);
if (DECL_CONSTRUCTOR_P (fun))
cx_check_missing_mem_inits (fun, body, true);
}
}
input_location = save_loc;
I don't understand the point of the first "if", since if it is ever not taken
it would be a bug.
However, in this case, interestingly, the "if" is taken, but then nothing else
prints any explanation. I didn't investigate in detail why.
Also, playing tricks with input_location is not so nice.
>From gcc-bugs-return-426417-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sat Jul 20 22:09:21 2013
Return-Path: <gcc-bugs-return-426417-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 21916 invoked by alias); 20 Jul 2013 22:09:21 -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 19551 invoked by uid 48); 20 Jul 2013 22:07:18 -0000
From: "david-gcc at klaftenegger dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/57942] New: g++-4.8.1 tries to instantiate wrong constructor (C++11)
Date: Sat, 20 Jul 2013 22:09: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: 4.8.1
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: david-gcc at klaftenegger dot de
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 attachments.created
Message-ID: <bug-57942-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-07/txt/msg00924.txt.bz2
Content-length: 2527
http://gcc.gnu.org/bugzilla/show_bug.cgi?idW942
Bug ID: 57942
Summary: g++-4.8.1 tries to instantiate wrong constructor
(C++11)
Product: gcc
Version: 4.8.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: david-gcc at klaftenegger dot de
Created attachment 30532
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id0532&actioníit
code exampe to trigger the bug
In the attached small C++11 code example g++ tries to instantiate the second
constructor of MyClass<int, false>, which should not happen.
As this code never requires MyClass<int, true>, it should compile, but due to
this useless instantiation g++ rejects the code.
To trigger the problem just run
$ g++-4.8 -std=c++11 g++-bug.cpp
This produces the following error output:
g++-bug.cpp: In instantiation of "class MyClass<int, true>":
g++-bug.cpp:26:27: required from here
g++-bug.cpp:6:7: error: base type "int" fails to be a struct or class type
Here is the exact compiler version used:
$ g++-4.8 -v
Using built-in specs.
COLLECT_GCC=g++-4.8
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
4.8.1-2ubuntu1~13.04' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs
--enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.8 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls
--with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin
--with-system-zlib --disable-browser-plugin --enable-java-awt=gtk
--enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre
--enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686
--with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 4.8.1 (Ubuntu 4.8.1-2ubuntu1~13.04)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/57941] [c++11] confusing error message with invalid constexpr constructor in template struct
2013-07-20 17:41 [Bug c++/57941] New: [c++11] confusing error message with invalid constexpr constructor in template struct f.heckenbach@fh-soft.de
2013-07-20 20:54 ` [Bug c++/57941] " manu at gcc dot gnu.org
@ 2014-11-03 10:31 ` paolo.carlini at oracle dot com
2014-11-18 3:44 ` jason at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: paolo.carlini at oracle dot com @ 2014-11-03 10:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57941
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |paolo.carlini at oracle dot com
--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> ---
In mainline we made progress on this issue (I should track down when and why):
after the "because" note we print:
57941.C:5:33: error: call to non-constexpr function ‘int a<T>::c() const [with
T = int]’
constexpr int b () { return c (); }
>From gcc-bugs-return-465625-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Nov 03 10:35:20 2014
Return-Path: <gcc-bugs-return-465625-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 26011 invoked by alias); 3 Nov 2014 10:35:20 -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 25922 invoked by uid 48); 3 Nov 2014 10:35:16 -0000
From: "marxin at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/63712] [5.0 regression] ICE in expand_expr_addr_expr_1, at expr.c:7662
Date: Mon, 03 Nov 2014 10:35:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: rtl-optimization
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords: build, ice-on-valid-code
X-Bugzilla-Severity: normal
X-Bugzilla-Who: marxin at gcc dot gnu.org
X-Bugzilla-Status: RESOLVED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: marxin at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 5.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status resolution
Message-ID: <bug-63712-4-pV8P5dgse9@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-63712-4@http.gcc.gnu.org/bugzilla/>
References: <bug-63712-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-11/txt/msg00097.txt.bz2
Content-length: 497
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63712
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
Dup.
*** This bug has been marked as a duplicate of bug 63573 ***
>From gcc-bugs-return-465626-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Nov 03 10:35:22 2014
Return-Path: <gcc-bugs-return-465626-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 26223 invoked by alias); 3 Nov 2014 10:35:22 -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 25968 invoked by uid 48); 3 Nov 2014 10:35:18 -0000
From: "marxin at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug bootstrap/63573] [5 Regression] libgo: ICE building libgo on powerpc-linux-gnu
Date: Mon, 03 Nov 2014 10:35:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: bootstrap
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords: ice-on-valid-code
X-Bugzilla-Severity: normal
X-Bugzilla-Who: marxin at gcc dot gnu.org
X-Bugzilla-Status: REOPENED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: marxin at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: cc
Message-ID: <bug-63573-4-ysGojcAsQu@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-63573-4@http.gcc.gnu.org/bugzilla/>
References: <bug-63573-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-11/txt/msg00098.txt.bz2
Content-length: 446
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63573
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |schwab@linux-m68k.org
--- Comment #9 from Martin Liška <marxin at gcc dot gnu.org> ---
*** Bug 63712 has been marked as a duplicate of this bug. ***
>From gcc-bugs-return-465627-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Nov 03 10:37:15 2014
Return-Path: <gcc-bugs-return-465627-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 28444 invoked by alias); 3 Nov 2014 10:37:15 -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 28373 invoked by uid 55); 3 Nov 2014 10:37:11 -0000
From: "glisse at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/63666] [5.0 regression] FAIL: gcc.dg/vect/pr45752.c (internal compiler error)
Date: Mon, 03 Nov 2014 10:37:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: tree-optimization
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: glisse at gcc dot gnu.org
X-Bugzilla-Status: RESOLVED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 5.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-63666-4-ZVqsDtZpuY@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-63666-4@http.gcc.gnu.org/bugzilla/>
References: <bug-63666-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-11/txt/msg00099.txt.bz2
Content-length: 550
https://gcc.gnu.org/bugzilla/show_bug.cgi?idc666
--- Comment #13 from Marc Glisse <glisse at gcc dot gnu.org> ---
Author: glisse
Date: Mon Nov 3 10:36:35 2014
New Revision: 217033
URL: https://gcc.gnu.org/viewcvs?rev!7033&root=gcc&view=rev
Log:
2014-11-03 Marc Glisse <marc.glisse@inria.fr>
PR tree-optimization/63666
* fold-const.c: Include "optabs.h".
(fold_ternary_loc) <VEC_PERM_EXPR>: Avoid canonicalizing a
can_vec_perm_p permutation to one that is not.
Modified:
trunk/gcc/ChangeLog
trunk/gcc/fold-const.c
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/57941] [c++11] confusing error message with invalid constexpr constructor in template struct
2013-07-20 17:41 [Bug c++/57941] New: [c++11] confusing error message with invalid constexpr constructor in template struct f.heckenbach@fh-soft.de
2013-07-20 20:54 ` [Bug c++/57941] " manu at gcc dot gnu.org
2014-11-03 10:31 ` paolo.carlini at oracle dot com
@ 2014-11-18 3:44 ` jason at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: jason at gcc dot gnu.org @ 2014-11-18 3:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57941
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |jason at gcc dot gnu.org
Resolution|--- |FIXED
Target Milestone|--- |5.0
--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for GCC 5, then.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-11-18 3:44 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-20 17:41 [Bug c++/57941] New: [c++11] confusing error message with invalid constexpr constructor in template struct f.heckenbach@fh-soft.de
2013-07-20 20:54 ` [Bug c++/57941] " manu at gcc dot gnu.org
2014-11-03 10:31 ` paolo.carlini at oracle dot com
2014-11-18 3:44 ` jason 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).