This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/82734] New: -Wignored-qualifiers is maybe too strict when using decltype


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

            Bug ID: 82734
           Summary: -Wignored-qualifiers is maybe too strict when using
                    decltype
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sylvestre at debian dot org
  Target Milestone: ---

With the following code:
#include <stdint.h>
#include <assert.h>

void foo() {
  const int BLOCK_SIZE = 42;
  static_assert(
    BLOCK_SIZE <
      static_cast<decltype(BLOCK_SIZE)>(INT32_MAX));
}

----
# g++-7 -c -Wall -Wignored-qualifiers foo.cpp
# g++-8 -c -Wall -Wignored-qualifiers foo.cpp
foo.cpp: In function 'void foo()':
foo.cpp:9:50: warning: type qualifiers ignored on cast result type
[-Wignored-qualifiers]
       static_cast<decltype(BLOCK_SIZE)>(INT32_MAX));
                                                  ^
----

Either:
* The warning is too strict. In some cases, I don't control what BLOCK_SIZE can
be and the const isn't a big deal
* I should have in the warning the definition of BLOCK_SIZE to have an idea of
what is going on.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]