[Bug c++/91678] [9/10 Regression] decltype returns wrong type under certain conditions

2019-12-07 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91678

--- Comment #6 from Marek Polacek  ---
Author: mpolacek
Date: Sat Dec  7 17:35:54 2019
New Revision: 279077

URL: https://gcc.gnu.org/viewcvs?rev=279077=gcc=rev
Log:
PR c++/91678 - wrong error with decltype and location wrapper.

Compiling this testcase results in a bogus "invalid cast" error; this occurs
since the introduction of location wrappers in finish_id_expression.

Here we are parsing the decltype expression via cp_parser_decltype_expr which
can lead to calling various fold_* and c-family routines.  They use
non_lvalue_loc, but that won't create a NON_LVALUE_EXPR wrapper around a
location
wrapper.

So before the location wrappers addition cp_parser_decltype_expr would return
NON_LVALUE_EXPR .  Now it returns VIEW_CONVERT_EXPR(c), but the
STRIP_ANY_LOCATION_WRAPPER immediately following it strips the location
wrapper,
and suddenly we don't know whether we have an lvalue anymore.  And that's sad
because then decltype produces the wrong type, causing nonsense errors.

* fold-const.c (maybe_lvalue_p): Handle VIEW_CONVERT_EXPR.

* g++.dg/cpp0x/decltype73.C: New test.

Added:
trunk/gcc/testsuite/g++.dg/cpp0x/decltype73.C
Modified:
trunk/gcc/ChangeLog
trunk/gcc/fold-const.c
trunk/gcc/testsuite/ChangeLog

[Bug c++/91678] [9/10 Regression] decltype returns wrong type under certain conditions

2019-12-03 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91678

--- Comment #5 from Marek Polacek  ---
Sorry, I'll try to respond to
https://gcc.gnu.org/ml/gcc-patches/2019-09/msg01042.html
soon.

It doesn't seem to fix Comment 4 though, will have to look why :/.

[Bug c++/91678] [9/10 Regression] decltype returns wrong type under certain conditions

2019-12-03 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91678

--- Comment #4 from Jonathan Wakely  ---
Marek, are you still working on the patch?

Does it also fix the testcase from PR 92766?

template
void foo(T&& begin, T&& end);

void test()
{
unsigned char buffer[16];
const unsigned char* ptr = buffer;
foo(ptr+0, ptr+8);
}

[Bug c++/91678] [9/10 Regression] decltype returns wrong type under certain conditions

2019-12-03 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91678

Jonathan Wakely  changed:

   What|Removed |Added

 CC||bisqwit at iki dot fi

--- Comment #3 from Jonathan Wakely  ---
*** Bug 92766 has been marked as a duplicate of this bug. ***

[Bug c++/91678] [9/10 Regression] decltype returns wrong type under certain conditions

2019-09-11 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91678

Marek Polacek  changed:

   What|Removed |Added

   Keywords||patch

--- Comment #2 from Marek Polacek  ---
Patch posted Sep 5:
https://gcc.gnu.org/ml/gcc-patches/2019-09/msg00330.html

[Bug c++/91678] [9/10 Regression] decltype returns wrong type under certain conditions

2019-09-05 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91678

Marek Polacek  changed:

   What|Removed |Added

   Target Milestone|--- |9.3

[Bug c++/91678] [9/10 Regression] decltype returns wrong type under certain conditions

2019-09-05 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91678

Marek Polacek  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
 CC||mpolacek at gcc dot gnu.org
   Assignee|unassigned at gcc dot gnu.org  |mpolacek at gcc dot 
gnu.org

[Bug c++/91678] [9/10 Regression] decltype returns wrong type under certain conditions

2019-09-05 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91678

Jonathan Wakely  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
  Known to work||8.3.0
Version|unknown |9.2.0
   Keywords||rejects-valid
   Last reconfirmed||2019-09-05
 CC||dmalcolm at gcc dot gnu.org
 Ever confirmed|0   |1
Summary|decltype returns wrong type |[9/10 Regression] decltype
   |under certain conditions|returns wrong type under
   ||certain conditions
  Known to fail||10.0, 9.2.0

--- Comment #1 from Jonathan Wakely  ---
Confirmed. This is a regression that started with r267272:

C++: more location wrapper nodes (PR c++/43064, PR c++/43486)