Skip to content

[clang] void is apparently referenceable #56014

@cjdb

Description

@cjdb

The following shouldn't be well-formed, but it is in Clang.

template<class T>
using with_reference = T&;

template<class T>
concept can_reference = requires {
  typename with_reference<T>;
};

template<class T>
concept dereferenceable = requires(T& t) {
  { *t } -> can_reference;
};

static_assert(dereferenceable<void*>);

Clang invocation: clang++ -std=c++20 -pedantic -pedantic-errors file.cpp

Version:

clang version 15.0.0 (https://github.com/llvm/llvm-project.git 186a13f647acac623898bcffa4b966624d2358ba)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-trunk/bin

Metadata

Metadata

Assignees

No one assigned

    Labels

    c++20clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerclang:frontendLanguage frontend issues, e.g. anything involving "Sema"conceptsC++20 conceptsinvalid-code-generationTool (e.g. clang-format) produced invalid code that no longer compiles

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions