Bug 59681 - SVN 197248 adding N3582 support broke Boost.Regex with -std=c++1y
Summary: SVN 197248 adding N3582 support broke Boost.Regex with -std=c++1y
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.9.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-05 03:56 UTC by Peter A. Bigot
Modified: 2019-08-09 20:33 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2014-01-05 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Peter A. Bigot 2014-01-05 03:56:49 UTC
In this commit 
http://gcc.gnu.org/viewcvs/gcc/trunk/gcc/cp/parser.c?r1=197248&r2=197247&pathrev=197248
the first diff (line 4109 of c/parser.c) fixed a problem where the
return value from finish_parenthesized_expr() was discarded.  As a side
effect, this small program:

#include <boost/regex.hpp>
const boost::regex e("AB");

produces these diagnostics with gcc -std=c++1y and Boost 1.55:

llc[45]$ /usr/local/gcc/bin/g++ --version
g++ (GCC) 4.9.0 20140104 (experimental)
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

llc[46]$ /usr/local/gcc/bin/g++ -std=c++1y -c /tmp/bre.cc 
In file included from /usr/local/gcc-20140104/include/boost/regex/v4/regex.hpp:70:0,
                 from /usr/local/gcc-20140104/include/boost/regex.hpp:31,
                 from /tmp/bre.cc:1:
/usr/local/gcc-20140104/include/boost/regex/v4/basic_regex_creator.hpp: In member function ‘boost::re_detail::re_literal* boost::re_detail::basic_regex_creator<charT, traits>::append_literal(charT)’:
/usr/local/gcc-20140104/include/boost/regex/v4/basic_regex_creator.hpp:349:24: error: lvalue required as increment operand
       ++(result->length);
                        ^
In file included from /usr/local/gcc-20140104/include/boost/regex/v4/regex.hpp:73:0,
                 from /usr/local/gcc-20140104/include/boost/regex.hpp:31,
                 from /tmp/bre.cc:1:
/usr/local/gcc-20140104/include/boost/regex/v4/basic_regex_parser.hpp: In member function ‘bool boost::re_detail::basic_regex_parser<charT, traits>::parse_repeat(std::size_t, std::size_t)’:
/usr/local/gcc-20140104/include/boost/regex/v4/basic_regex_parser.hpp:974:21: error: lvalue required as decrement operand
       --(lit->length);
                     ^
llc[47]$

The problem goes away if that line of the patch is reverted, but since
the change appears to be correct there's some other problem somewhere.
Comment 1 Andrew Pinski 2014-01-05 04:35:44 UTC
Is (a) an lvalue still?  I don't remember the C++ rules to tell you the truth.
Comment 2 Jonathan Wakely 2014-01-05 08:58:16 UTC
[expr.prim.general] p6 says:

A parenthesized expression is a primary expression whose type and value are identical to those of the enclosed expression. The presence of parentheses does not affect whether the expression is an lvalue. The parenthesized expression can be used in exactly the same contexts as those where the enclosed expression
can be used, and with the same meaning, except as otherwise indicated.
Comment 3 Peter A. Bigot 2014-01-05 19:46:45 UTC
But also note [dcl.type.simple] p4:

The type denoted by decltype(e) is defined as follows:
— if e is an unparenthesized id-expression or an unparenthesized class member access (5.2.5), decltype(e) is the type of the entity named by e. If there is no such entity, or if e names a set of overloaded functions, the program is ill-formed;
— otherwise, if e is an xvalue, decltype(e) is T&&, where T is the type of e;
— otherwise, if e is an lvalue, decltype(e) is T&, where T is the type of e;
— otherwise, decltype(e) is the type of e.
The operand of the decltype specifier is an unevaluated operand (Clause 5).

which means decltype((e)) is not necessarily the same as decltype(e).

Perhaps the change was made to make this work, but it has side effects in some context that does not (explicitly) use decltype.
Comment 4 Paolo Carlini 2014-01-24 11:32:02 UTC
Let's add Jason in CC.
Comment 5 Marek Polacek 2019-08-09 20:33:11 UTC
$ xg++ -c 59681.C -std=c++1y
# nothing

so assuming fixed.