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

            Bug ID: 98061
           Summary: CV qualifiers are incorrectly stripped from the type
                    of void prvalues
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jason.e.cobb at gmail dot com
  Target Milestone: ---

When creating a prvalue of a cv void type, cv qualifiers are incorrectly
stripped.

Consider:
BEGIN EXAMPLE

#include <type_traits>

template<typename T>
using id_t = T;

static_assert(std::is_same_v<decltype(id_t<void const>()), void>);

END EXAMPLE

On Compiler Explorer: https://godbolt.org/z/z3PebY

GCC, Clang, and MSVC accept. ICC rejects, believing the type to instead be
const void (https://godbolt.org/z/Tqvjoo). The results are similar for
volatile.

ICC is correct. The correct type is const void per [expr.type.conv]/2:
> Otherwise, if the type is cv void and the initializer is () or {} (after pack 
> expansion, if any), the expression is a prvalue of the specified type that 
> performs no initialization.
  • [Bug c++/98061] New: CV qualifi... jason.e.cobb at gmail dot com via Gcc-bugs

Reply via email to