public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/116198] New: Wdeprecated-enum-enum-conversion triggers inside extern "C"
@ 2024-08-02 17:29 rsaxvc at gmail dot com
  2024-08-02 17:32 ` [Bug c++/116198] " sjames at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: rsaxvc at gmail dot com @ 2024-08-02 17:29 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 116198
           Summary: Wdeprecated-enum-enum-conversion triggers inside
                    extern "C"
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rsaxvc at gmail dot com
  Target Milestone: ---

deprecated-enum-enum-conversion warnings apply to C code compiled by G++,
should they? I'm assuming if this code would not trigger a warning in C, it
shouldn't trigger a warning in extern "C". Here's a minimal contrived example:

   #include <stdlib.h>

   extern "C"{
      enum {TWO = 2};
      enum {ONE = 1};
      void * triggerDeprecatedEnumConversion() {
         return malloc(ONE | TWO);
      }
   }

When the above code is compiled with g++ 12.2.0, -Wall -Wextra -O2 -std=c++23,
triggers this warning:

   <source>: In function 'void* triggerDeprecatedEnumConversion()':
   <source>:17:27: warning: bitwise operation between different enumeration
types '<unnamed enum>' and '<unnamed enum>' is deprecated
[-Wdeprecated-enum-enum-conversion]
      17 |         return malloc(ONE | TWO);
         |                       ~~~~^~~~~

One real-world use-case this impacts occurs in LVGL, which uses separate enums
for different parts of a bitfield that are then combined in functions in a
header, so every C++ file that includes those headers triggers this warning.
Related discussion here: https://github.com/lvgl/lvgl/issues/5119

Specific compiler version:
   xtensa-esp32s3-elf-c++.exe (crosstool-NG esp-12.2.0_20230208) 12.2.0
   Copyright (C) 2022 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.

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

* [Bug c++/116198] Wdeprecated-enum-enum-conversion triggers inside extern "C"
  2024-08-02 17:29 [Bug c++/116198] New: Wdeprecated-enum-enum-conversion triggers inside extern "C" rsaxvc at gmail dot com
@ 2024-08-02 17:32 ` sjames at gcc dot gnu.org
  2024-08-02 17:33 ` pinskia at gcc dot gnu.org
  2024-08-02 17:39 ` rsaxvc at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-08-02 17:32 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Sam James <sjames at gcc dot gnu.org> ---
extern "C" does _not_ change the language something is built as, just linkage.

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

* [Bug c++/116198] Wdeprecated-enum-enum-conversion triggers inside extern "C"
  2024-08-02 17:29 [Bug c++/116198] New: Wdeprecated-enum-enum-conversion triggers inside extern "C" rsaxvc at gmail dot com
  2024-08-02 17:32 ` [Bug c++/116198] " sjames at gcc dot gnu.org
@ 2024-08-02 17:33 ` pinskia at gcc dot gnu.org
  2024-08-02 17:39 ` rsaxvc at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-08-02 17:33 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
           See Also|                            |https://github.com/lvgl/lvg
                   |                            |l/issues/5119
         Resolution|---                         |INVALID

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Why do you think `extern "C"` changes the language? It does not it just changes
the linkage.

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

* [Bug c++/116198] Wdeprecated-enum-enum-conversion triggers inside extern "C"
  2024-08-02 17:29 [Bug c++/116198] New: Wdeprecated-enum-enum-conversion triggers inside extern "C" rsaxvc at gmail dot com
  2024-08-02 17:32 ` [Bug c++/116198] " sjames at gcc dot gnu.org
  2024-08-02 17:33 ` pinskia at gcc dot gnu.org
@ 2024-08-02 17:39 ` rsaxvc at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: rsaxvc at gmail dot com @ 2024-08-02 17:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from rsaxvc at gmail dot com ---
Thanks, that makes sense. I didn't realize that any code in a header would need
to be able to compile as any language including that header, so we'll need to
fix LVGL.

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

end of thread, other threads:[~2024-08-02 17:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-02 17:29 [Bug c++/116198] New: Wdeprecated-enum-enum-conversion triggers inside extern "C" rsaxvc at gmail dot com
2024-08-02 17:32 ` [Bug c++/116198] " sjames at gcc dot gnu.org
2024-08-02 17:33 ` pinskia at gcc dot gnu.org
2024-08-02 17:39 ` rsaxvc at gmail dot com

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).