public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/106213] New: -Werror=deprecated-copy-dtor does not trigger warning and error
@ 2022-07-06  9:55 federico.kircheis at gmail dot com
  2022-07-06 20:41 ` [Bug c++/106213] " pinskia at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: federico.kircheis at gmail dot com @ 2022-07-06  9:55 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 106213
           Summary: -Werror=deprecated-copy-dtor does not trigger warning
                    and error
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: federico.kircheis at gmail dot com
  Target Milestone: ---

Consider

struct s{
    int* i;
    s();
    ~s(){ delete i;}
};


void bar(){
    s instance;
    s instance2 = instance;
}

This code compiles without warnings (gcc12) unless using
"-Wdeprecated-copy-dtor"

I would like it to be an error, so I've used "-Werror=deprecated-copy-dtor",
but
 * it does not trigger an error
 * it does not even trigger a warning(!!!)

The minimal example

https://godbolt.org/z/9b98Gsz1n

"-Werror -Wdeprecated-copy-dtor" works, but it might turn other warnings into
error, so it is not desirable.
Also the output of "-Werror -Wdeprecated-copy-dtor" mentions
"-Werror=deprecated-copy-dtor", so it should work.

A possible workaround is using "-Werror=deprecated-copy-dtor
-Wdeprecated-copy-dtor", but it should not be necessary.

Other flags, like Wreorder, works correclty: https://godbolt.org/z/zrr1GbK4K

As far as I've tested, "-Werror=deprecated-copy-dtor" never worked.

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

* [Bug c++/106213] -Werror=deprecated-copy-dtor does not trigger warning and error
  2022-07-06  9:55 [Bug c++/106213] New: -Werror=deprecated-copy-dtor does not trigger warning and error federico.kircheis at gmail dot com
@ 2022-07-06 20:41 ` pinskia at gcc dot gnu.org
  2022-07-06 20:42 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-07-06 20:41 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-07-06
           Keywords|                            |diagnostic
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

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

* [Bug c++/106213] -Werror=deprecated-copy-dtor does not trigger warning and error
  2022-07-06  9:55 [Bug c++/106213] New: -Werror=deprecated-copy-dtor does not trigger warning and error federico.kircheis at gmail dot com
  2022-07-06 20:41 ` [Bug c++/106213] " pinskia at gcc dot gnu.org
@ 2022-07-06 20:42 ` pinskia at gcc dot gnu.org
  2022-07-06 20:46 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-07-06 20:42 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=94492

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
      /* Don't warn if the flag was disabled around the class definition
         (c++/94492).  */
      if (warning_enabled_at (DECL_SOURCE_LOCATION (decl),
                              OPT_Wdeprecated_copy))
        {
          auto_diagnostic_group d;
          tree ctx = DECL_CONTEXT (decl);
          tree other = classtype_has_depr_implicit_copy (ctx);
          int opt = (DECL_DESTRUCTOR_P (other)
                     ? OPT_Wdeprecated_copy_dtor
                     : OPT_Wdeprecated_copy);

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

* [Bug c++/106213] -Werror=deprecated-copy-dtor does not trigger warning and error
  2022-07-06  9:55 [Bug c++/106213] New: -Werror=deprecated-copy-dtor does not trigger warning and error federico.kircheis at gmail dot com
  2022-07-06 20:41 ` [Bug c++/106213] " pinskia at gcc dot gnu.org
  2022-07-06 20:42 ` pinskia at gcc dot gnu.org
@ 2022-07-06 20:46 ` pinskia at gcc dot gnu.org
  2023-12-19 20:42 ` jason at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-07-06 20:46 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=88136

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Not a regression though, it was introduced when -Wdeprecated-copy-dtor was
introduced (PR 88136).

It is another one of these option oddities as  -Wdeprecated-copy-dtor also
enables -Wdeprecated-copy but sets the variable to 2 and such.

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

* [Bug c++/106213] -Werror=deprecated-copy-dtor does not trigger warning and error
  2022-07-06  9:55 [Bug c++/106213] New: -Werror=deprecated-copy-dtor does not trigger warning and error federico.kircheis at gmail dot com
                   ` (2 preceding siblings ...)
  2022-07-06 20:46 ` pinskia at gcc dot gnu.org
@ 2023-12-19 20:42 ` jason at gcc dot gnu.org
  2023-12-21  2:07 ` cvs-commit at gcc dot gnu.org
  2023-12-21 21:59 ` jason at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2023-12-19 20:42 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |jason at gcc dot gnu.org
                 CC|                            |jason at gcc dot gnu.org

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

* [Bug c++/106213] -Werror=deprecated-copy-dtor does not trigger warning and error
  2022-07-06  9:55 [Bug c++/106213] New: -Werror=deprecated-copy-dtor does not trigger warning and error federico.kircheis at gmail dot com
                   ` (3 preceding siblings ...)
  2023-12-19 20:42 ` jason at gcc dot gnu.org
@ 2023-12-21  2:07 ` cvs-commit at gcc dot gnu.org
  2023-12-21 21:59 ` jason at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-12-21  2:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:32bab8b57ddf0df727f5eaf99a77e70882c4e6e2

commit r14-6764-g32bab8b57ddf0df727f5eaf99a77e70882c4e6e2
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Dec 19 15:33:07 2023 -0500

    opts: -Werror=foo always implies -Wfoo [PR106213]

    -Werror=foo implying -Wfoo wasn't working for -Wdeprecated-copy-dtor,
    because it is specified as the value 2 of warn_deprecated_copy, which shows
    up as CLVC_EQUAL, which is not one of the three var_types handled by
    control_warning_option.  It seems to me that we can just unconditionally
    handle_generated_option, and only have special argument handling for those
    types.

            PR c++/106213

    gcc/ChangeLog:

            * opts-common.cc (control_warning_option): Call
            handle_generated_option for all cl_var_types.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/depr-copy5.C: New test.

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

* [Bug c++/106213] -Werror=deprecated-copy-dtor does not trigger warning and error
  2022-07-06  9:55 [Bug c++/106213] New: -Werror=deprecated-copy-dtor does not trigger warning and error federico.kircheis at gmail dot com
                   ` (4 preceding siblings ...)
  2023-12-21  2:07 ` cvs-commit at gcc dot gnu.org
@ 2023-12-21 21:59 ` jason at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2023-12-21 21:59 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
   Target Milestone|---                         |14.0
             Status|ASSIGNED                    |RESOLVED

--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for GCC 14.

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

end of thread, other threads:[~2023-12-21 21:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-06  9:55 [Bug c++/106213] New: -Werror=deprecated-copy-dtor does not trigger warning and error federico.kircheis at gmail dot com
2022-07-06 20:41 ` [Bug c++/106213] " pinskia at gcc dot gnu.org
2022-07-06 20:42 ` pinskia at gcc dot gnu.org
2022-07-06 20:46 ` pinskia at gcc dot gnu.org
2023-12-19 20:42 ` jason at gcc dot gnu.org
2023-12-21  2:07 ` cvs-commit at gcc dot gnu.org
2023-12-21 21:59 ` jason at gcc dot gnu.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).