public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/55708] New: g++ crashes: constexpr function with reference parameters.
@ 2012-12-15 13:00 lundberj at gmail dot com
2013-04-26 11:52 ` [Bug c++/55708] " paolo.carlini at oracle dot com
2013-04-26 12:19 ` paolo.carlini at oracle dot com
0 siblings, 2 replies; 3+ messages in thread
From: lundberj at gmail dot com @ 2012-12-15 13:00 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55708
Bug #: 55708
Summary: g++ crashes: constexpr function with reference
parameters.
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: lundberj@gmail.com
The following code crashes g++ 4.8-20121209 (and gcc 4.7.2). The issue occurs
with some uses of the result of a constexpr function with reference parameters
(&& or &).
Both the normal template do_y() and user defoned literal _y() shows exactly the
same problem, via the assert at cp/pt.c:14334.
Perhaps related: bug 49514, http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49514
Full example:
template<int N,int NNN>
struct AA { static constexpr int val = N; };
template<typename A,typename B>
//constexpr unsigned long long mymax(A a,B b){ // <-- compiles
constexpr unsigned long long mymax(A && a,const B& b){
return a<b?b:a;
}
template<char... List>
constexpr long long operator"" _y() noexcept
{
return AA<1, mymax(1,2)>::val; // <-- crashes gcc
// return mymax(1,2); // <-- compiles
// return AA<1,2>::val; // <-- compiles
}
template<char... List>
constexpr unsigned long long do_y() noexcept
{
return AA<1, mymax(1,2)>::val; <-- crashes gcc
}
int main(){
return 1_y + do_y() ;
}
I compiled with g++ -Wall -Wextra file.cpp -std=c++11
Here's the full g++ printout:
In function ‘constexpr long long int operator"" _y()’:
internal compiler error: in tsubst_copy_and_build, at cp/pt.c:14334
return AA<1, mymax(1,2)>::val;
^
0x81a4dc9 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
../.././gcc/cp/pt.c:14334
0x81ed922 tsubst_non_call_postfix_expression
../.././gcc/cp/pt.c:13229
0x81a0422 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
../.././gcc/cp/pt.c:13452
0x81a0a99 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
../.././gcc/cp/pt.c:13352
0x81a1439 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
../.././gcc/cp/pt.c:13760
0x81a5c3a fold_non_dependent_expr_sfinae(tree_node*, int)
../.././gcc/cp/pt.c:5081
0x81c48bd convert_nontype_argument
../.././gcc/cp/pt.c:5493
0x81c48bd convert_template_argument
../.././gcc/cp/pt.c:6383
0x81ca30b coerce_template_parms
../.././gcc/cp/pt.c:6722
0x81cc506 lookup_template_class_1
../.././gcc/cp/pt.c:7226
0x81cc506 lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*,
int, int)
../.././gcc/cp/pt.c:7523
0x82dbc87 finish_template_type(tree_node*, tree_node*, int)
../.././gcc/cp/semantics.c:2791
0x8267f40 cp_parser_template_id
../.././gcc/cp/parser.c:12707
0x826834a cp_parser_class_name
../.././gcc/cp/parser.c:18105
0x825cf49 cp_parser_qualifying_entity
../.././gcc/cp/parser.c:5276
0x825cf49 cp_parser_nested_name_specifier_opt
../.././gcc/cp/parser.c:5007
0x8275975 cp_parser_simple_type_specifier
../.././gcc/cp/parser.c:13882
0x825be2a cp_parser_postfix_expression
../.././gcc/cp/parser.c:5551
0x825e5ab cp_parser_unary_expression
../.././gcc/cp/parser.c:6686
0x825f185 cp_parser_binary_expression
../.././gcc/cp/parser.c:7360
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/55708] g++ crashes: constexpr function with reference parameters.
2012-12-15 13:00 [Bug c++/55708] New: g++ crashes: constexpr function with reference parameters lundberj at gmail dot com
@ 2013-04-26 11:52 ` paolo.carlini at oracle dot com
2013-04-26 12:19 ` paolo.carlini at oracle dot com
1 sibling, 0 replies; 3+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-04-26 11:52 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55708
--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2013-04-26 11:52:30 UTC ---
Thanks Daniel. I'm going to add the testcase and close the PR as fixed for
4.9.0.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/55708] g++ crashes: constexpr function with reference parameters.
2012-12-15 13:00 [Bug c++/55708] New: g++ crashes: constexpr function with reference parameters lundberj at gmail dot com
2013-04-26 11:52 ` [Bug c++/55708] " paolo.carlini at oracle dot com
@ 2013-04-26 12:19 ` paolo.carlini at oracle dot com
1 sibling, 0 replies; 3+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-04-26 12:19 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55708
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Known to work| |4.9.0
Resolution| |FIXED
Target Milestone|--- |4.9.0
Severity|major |normal
--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2013-04-26 12:19:55 UTC ---
Done.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-04-26 12:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-15 13:00 [Bug c++/55708] New: g++ crashes: constexpr function with reference parameters lundberj at gmail dot com
2013-04-26 11:52 ` [Bug c++/55708] " paolo.carlini at oracle dot com
2013-04-26 12:19 ` paolo.carlini at oracle dot com
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).