public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/18474] Unary plus/minus lvalueness not diagnosed in templates
       [not found] <bug-18474-4@http.gcc.gnu.org/bugzilla/>
@ 2022-12-07  2:53 ` pinskia at gcc dot gnu.org
  2023-09-18 18:48 ` cvs-commit at gcc dot gnu.org
  2023-09-18 19:13 ` ppalka at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-12-07  2:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=18474

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note this is only invalid as n (if declared correctly) was not depedent so the
operator lookup would be bound at definition time.

That is the following needs to be accepted still:
template <class T>
void g(void)
{
  T n;
  -n = 0;
  +n = 0;
}

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/18474] Unary plus/minus lvalueness not diagnosed in templates
       [not found] <bug-18474-4@http.gcc.gnu.org/bugzilla/>
  2022-12-07  2:53 ` [Bug c++/18474] Unary plus/minus lvalueness not diagnosed in templates pinskia at gcc dot gnu.org
@ 2023-09-18 18:48 ` cvs-commit at gcc dot gnu.org
  2023-09-18 19:13 ` ppalka at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-09-18 18:48 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=18474

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:6e92a6a2a72d3b7a5e1b29042d8a6a43fe1085aa

commit r14-4111-g6e92a6a2a72d3b7a5e1b29042d8a6a43fe1085aa
Author: Patrick Palka <ppalka@redhat.com>
Date:   Mon Sep 18 14:47:52 2023 -0400

    c++: non-dependent assignment checking [PR63198, PR18474]

    This patch makes us recognize and check non-dependent simple assigments
    ahead of time, like we already do for compound assignments.  This means
    the templated representation of such assignments will now usually have
    an implicit INDIRECT_REF (due to the reference return type), which the
    -Wparentheses code needs to handle.  As a drive-by improvement, this
    patch also makes maybe_convert_cond issue -Wparentheses warnings ahead
    of time, and removes a seemingly unnecessary suppress_warning call in
    build_x_modify_expr.

    On the libstdc++ side, some tests were attempting to modify a data
    member from a uninstantiated const member function, which this patch
    minimally fixes by making the data member mutable.

            PR c++/63198
            PR c++/18474

    gcc/cp/ChangeLog:

            * semantics.cc (maybe_convert_cond): Look through implicit
            INDIRECT_REF when deciding whether to issue a -Wparentheses
            warning, and consider templated assignment expressions as well.
            (finish_parenthesized_expr): Look through implicit INDIRECT_REF
            when suppressing -Wparentheses warning.
            * typeck.cc (build_x_modify_expr): Check simple assignments
            ahead time too, not just compound assignments.  Give the second
            operand of MODOP_EXPR a non-null type so that it's not considered
            always instantiation-dependent.  Don't call suppress_warning.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/static_assert15.C: Expect diagnostic for
            non-constant static_assert condition.
            * g++.dg/expr/unary2.C: Remove xfails.
            * g++.dg/template/init7.C: Make initializer type-dependent to
            preserve intent of test.
            * g++.dg/template/recurse3.C: Likewise for the erroneous
            statement.
            * g++.dg/template/non-dependent26.C: New test.
            * g++.dg/warn/Wparentheses-32.C: New test.

    libstdc++-v3/ChangeLog:

            *
testsuite/26_numerics/random/discard_block_engine/cons/seed_seq2.cc:
            Make data member seed_seq::called mutable.
            *
testsuite/26_numerics/random/independent_bits_engine/cons/seed_seq2.cc:
            Likewise.
            *
testsuite/26_numerics/random/linear_congruential_engine/cons/seed_seq2.cc:
            Likewise.
            *
testsuite/26_numerics/random/mersenne_twister_engine/cons/seed_seq2.cc:
            Likewise.
            *
testsuite/26_numerics/random/shuffle_order_engine/cons/seed_seq2.cc:
            Likewise.
            *
testsuite/26_numerics/random/subtract_with_carry_engine/cons/seed_seq2.cc:
            Likewise.
            *
testsuite/ext/random/simd_fast_mersenne_twister_engine/cons/seed_seq2.cc:
            Likewise.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/18474] Unary plus/minus lvalueness not diagnosed in templates
       [not found] <bug-18474-4@http.gcc.gnu.org/bugzilla/>
  2022-12-07  2:53 ` [Bug c++/18474] Unary plus/minus lvalueness not diagnosed in templates pinskia at gcc dot gnu.org
  2023-09-18 18:48 ` cvs-commit at gcc dot gnu.org
@ 2023-09-18 19:13 ` ppalka at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-09-18 19:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=18474

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppalka at gcc dot gnu.org
             Status|NEW                         |RESOLVED
   Target Milestone|---                         |14.0
         Resolution|---                         |FIXED
           Assignee|unassigned at gcc dot gnu.org      |ppalka at gcc dot gnu.org

--- Comment #4 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 14.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/18474] Unary plus/minus lvalueness not diagnosed in templates
  2004-11-14 10:51 [Bug c++/18474] New: " giovannibajo at libero dot it
@ 2004-11-14 17:18 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-11-14 17:18 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-11-14 17:18 -------
Confirmed. Note the testcase is not full you have to have a declaration for n.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-11-14 17:18:29
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18474


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-09-18 19:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-18474-4@http.gcc.gnu.org/bugzilla/>
2022-12-07  2:53 ` [Bug c++/18474] Unary plus/minus lvalueness not diagnosed in templates pinskia at gcc dot gnu.org
2023-09-18 18:48 ` cvs-commit at gcc dot gnu.org
2023-09-18 19:13 ` ppalka at gcc dot gnu.org
2004-11-14 10:51 [Bug c++/18474] New: " giovannibajo at libero dot it
2004-11-14 17:18 ` [Bug c++/18474] " pinskia at gcc dot gnu dot 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).