[llvm-bugs] [Bug 48331] New: CV qualifiers are incorrectly stripped from the type of void prvalues

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Nov 29 16:35:14 PST 2020


https://bugs.llvm.org/show_bug.cgi?id=48331

            Bug ID: 48331
           Summary: CV qualifiers are incorrectly stripped from the type
                    of void prvalues
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: jason.e.cobb at gmail.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201130/42350c19/attachment.html>


More information about the llvm-bugs mailing list