LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 15713 - Implement MSVC's language extension to form pointers to members of virtual bases
Summary: Implement MSVC's language extension to form pointers to members of virtual bases
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: C++ (show other bugs)
Version: unspecified
Hardware: PC Windows NT
: P enhancement
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks: 13707
  Show dependency tree
 
Reported: 2013-04-09 15:01 PDT by Reid Kleckner
Modified: 2019-12-02 13:50 PST (History)
5 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Reid Kleckner 2013-04-09 15:01:02 PDT
Clang currently rejects this program, as the standard says it is ill-formed in [conv.mem], I think:

struct A { int a; };
struct B : virtual A { int b; };
int B::*memptr_b = &B::a;  // error
----
memptr_data_virtual.cpp:8:20: error: conversion from pointer to member of class 'A' to pointer to member of class 'B' via virtual base 'A' is not allowed
int B::*memptr_b = &B::a;  // error

MSVC accepts this program, and has a whole bunch of machinery baked into the ABI to support it.  Data member pointers can be formed with up to 3 (!) i32s.

There's basically no way to implement this within the Itanium ABI since data memptrs there are always just one offset, so this would only be in -fms-compatibility (or -fms-extensions, I forget which is which).

Mostly I'm just filing this to have a discussion of record with a decision to implement or not.  We should document this as part of http://clang.llvm.org/compatibility.html, probably.
Comment 1 Timur Iskhodzhanov 2013-04-12 06:31:42 PDT
I think it's perfectly fine to not support it until we observe a real code that actually uses it and has some very strong reasons to use this bad pattern.
Comment 2 Reid Kleckner 2013-04-12 11:50:22 PDT
Right, I'm mostly just filing the PR to document the state.

FWIW I think John said it best in the code review.  This isn't a bad pattern, it's just a feature that MSVC implemented which was pared down during standardization.
Comment 3 Nico Weber 2015-06-23 14:29:47 PDT
r240383, r240384 removed a few FIXMEs pointing to this bug. (The bug is still valid though.)

Since we haven't needed this yet, it's probably ok to WontFix it if it's only implementable on Windows.
Comment 4 Anton Kochkov 2019-11-29 09:28:19 PST
Is this bug still relevant? Because it is mentioned at the MSVC compatibility page and was updated 4 years ago...

https://clang.llvm.org/docs/MSVCCompatibility.html
Comment 5 Reid Kleckner 2019-12-02 13:50:10 PST
Yeah, we implemented this a long time ago.