Opened 12 years ago

Closed 12 years ago

#4453 closed Bugs (fixed)

is_virtual_base_of uses common names for internal types (X and Y); naming conflicts result

Reported by: Karl Voelker <ktvoelker@…> Owned by: John Maddock
Milestone: To Be Determined Component: type_traits
Version: Boost Development Trunk Severity: Problem
Keywords: Cc:

Description

is_virtual_base_of (and probably a lot of other type traits, I suspect) uses some structs internally, X and Y, which inherit from the types being analyzed. But if the derived type under analysis (from which Y inherits) has a method Y, the constructor Y::Y in the internal struct becomes a problem. (At least, under gcc 4.5.0 20100520 prerelease.)

I've attached a simple demonstration of the problem. I attempted to compile with: g++ -c MyDerived.cpp.

One obvious solution to this problem is to change X and Y to have bizarre names that are unlikely to conflict with user code. I have attached a patch to this effect. However, I suspect that this problem occurs in many other type traits.

I'm not enough of a C++ spec expert to say whether my program ought to compile or not. Sorry. The real-world case from which my example was distilled is known to compile on MSVC++. I do not have access to MSVC++ to test my distillation.

Attachments (3)

fix.patch (1.1 KB ) - added by Karl Voelker <ktvoelker@…> 12 years ago.
Patch for the problem
boost-tt-bug.tar (20.0 KB ) - added by Karl Voelker <ktvoelker@…> 12 years ago.
Example of the problem
out.txt (1.0 KB ) - added by Karl Voelker <ktvoelker@…> 12 years ago.
My compiler output for the example

Download all attachments as: .zip

Change History (5)

by Karl Voelker <ktvoelker@…>, 12 years ago

Attachment: fix.patch added

Patch for the problem

by Karl Voelker <ktvoelker@…>, 12 years ago

Attachment: boost-tt-bug.tar added

Example of the problem

by Karl Voelker <ktvoelker@…>, 12 years ago

Attachment: out.txt added

My compiler output for the example

comment:1 by John Maddock, 12 years ago

Status: newassigned

comment:2 by John Maddock, 12 years ago

Resolution: fixed
Status: assignedclosed

(In [64251]) Mangle the names of internal classes so they're less likely to conflict with derived class names and members. Fixes #4453.

Note: See TracTickets for help on using tickets.