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

            Bug ID: 102730
           Summary: Consistency of deprecation warning emission with type
                    alias
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: romain.geissler at amadeus dot com
  Target Milestone: ---

Hi,

While trying to rename an enum from one name to another in an existing
framework, I try to use the following mechanism that works partially with gcc
(but not clang) of:
 - deprecating the old type declaration with [[deprecated]]
 - use some "using NewType = DeprecatedType;" statement to define the new name
our user shall use in their code.

I would expect that gcc correctly emit a warning when we use "DeprecatedType"
instead of "NewType" in the code, but not when I use "NewType", which allows
people to migrate to the new name without any impact on name mangling implied
by this name change. It seems that it works partially. See this snippet:

<<END_OF_FILE
enum [[deprecated]] DeprecatedEnum_t {};
class [[deprecated]] DeprecatedClass {};

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" 
using NewEnum_t = DeprecatedEnum_t;
using NewClass = DeprecatedClass;
#pragma GCC diagnostic pop

NewEnum_t f(); // No deprecation warning here
NewClass g(); // No deprecation warning here

void f(NewEnum_t); // Deprecation warning here
void g(NewClass); // Deprecation warning here
END_OF_FILE

I am aware that I am putting some expectation on some edge cases of gcc, clang
doesn't have the same behavior at all. But still, i don't get the inconsistency
on gcc side: I can use NewClass as a return type without warning, but not as a
parameter. It is expected ? Do we fall into some undefined behavior on the
compiler side here and compiler is free to implement whatever logic ?

Thanks,
Romain

Reply via email to