Message ID | 978b70fd-2c32-33c0-2697-92bdead883a0@oracle.com |
---|---|
State | New |
Headers | show |
Series | [C++] PR 81061 ("[7/8 Regression] ICE modifying read-only variable") | expand |
OK. On Wed, Dec 13, 2017 at 5:32 AM, Paolo Carlini <paolo.carlini@oracle.com> wrote: > Hi, > > in this simple error recovery regression we ICE during gimplification after > sensible diagnostic about assigning to a read-only location. The problem can > be avoided by simply returning immediately error_mark_node upon > cxx_readonly_error - the rest of the function does the same, ie, doesn't try > to proceed when complain & tf_error. I also noticed that clang appears to > behave in the same way for this error. Tested x86_64-linux. > > Thanks, Paolo > > //////////////////////// >
Index: cp/typeck.c =================================================================== --- cp/typeck.c (revision 255602) +++ cp/typeck.c (working copy) @@ -8037,8 +8037,7 @@ cp_build_modify_expr (location_t loc, tree lhs, en { if (complain & tf_error) cxx_readonly_error (lhs, lv_assign); - else - return error_mark_node; + return error_mark_node; } /* If storing into a structure or union member, it may have been given a Index: testsuite/g++.dg/other/const5.C =================================================================== --- testsuite/g++.dg/other/const5.C (nonexistent) +++ testsuite/g++.dg/other/const5.C (working copy) @@ -0,0 +1,8 @@ +// PR c++/81061 + +const int i = 0; + +void foo() +{ + (0, i) = 1; // { dg-error "read-only" } +}