[llvm-bugs] [Bug 34368] New: Const-qualified derived object can call a non-const base member-function.

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Aug 30 01:14:46 PDT 2017


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

            Bug ID: 34368
           Summary: Const-qualified derived object can call a non-const
                    base member-function.
           Product: clang
           Version: 4.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++14
          Assignee: unassignedclangbugs at nondot.org
          Reporter: delrieutheo at gmail.com
                CC: llvm-bugs at lists.llvm.org

Hello, I have the bug same bug than the one reported in
https://bugs.llvm.org/show_bug.cgi?id=27398.

The funny thing is that when compiling with -std=c++1z, the code correctly gets
rejected, whereas -std=c++11/14 doesn't emit any error.

#include <utility>

struct base
{
  void f() {}
};

struct derived : base{};

int main(int argc, char const *argv[])
{
  derived const d;

  using should_not_compile = decltype((std::declval<derived
const&>().*std::declval<decltype(&base::f)>())());
}

Is there a workaround to that? I started to implement traits
(is_correctly_cv_qualified and such) but that'd be great if I could solve this
in an easier way.

-- 
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/20170830/d3e3fba5/attachment.html>


More information about the llvm-bugs mailing list