Opened 12 years ago

Closed 8 years ago

#4763 closed Bugs (fixed)

boost/units/detail/utility.hpp uses gcc demangle API which is not available on clang

Reported by: sefi@… Owned by: Jürgen Hunold
Milestone: Boost 1.57.0 Component: units
Version: Boost 1.44.0 Severity: Problem
Keywords: Cc:

Description

The check in the header looks like this: #if defined(__GLIBCXX__) || defined(__GLIBCPP__)

However, clang++ also defines (at least one of) these macros but doesn't offer the gcc demangle API, so anything that uses this header will fail to compile on clang (like boost/exception/detail/type_info.hpp - The fact that this header includes a detail header from another library is, in my opinion, a bug in itself that should be fixed).

I "fixed" this by changing the line into: #if !defined(__clang__) && (defined(__GLIBCXX__) || defined(__GLIBCPP__))

I think this isn't a real fix. boost should use something like configure checks to see if abi::__cxa_demangle is actually usable.

Attachments (2)

units_detail_utility.patch (473 bytes ) - added by Michel MORIN <mimomorin@…> 11 years ago.
A patch for boost/units/detail/utility.hpp (against trunk r73307).
units_detail_utility.2.patch (747 bytes ) - added by Michel MORIN <mimomorin@…> 11 years ago.
A new patch for boost/units/detail/utility.hpp. This patch enables to detect <cxxabi.h> header file when compiling with clang.

Download all attachments as: .zip

Change History (10)

comment:1 by anonymous, 12 years ago

I just tried to compile boost/units/detail/utility.hpp with clang (trunk from monday) and no errors. I think the issue is not clang itself, but the C++ standard library used with it: I am using libstdc++ that came with gcc 4.2.

But using another standard library does not mean that abi::__cxa_demangle (the function used by utility.hpp) does not exist, as that function is not gcc-specific, but part of the C++ ABI: http://www.codesourcery.com/public/cxx-abi/abi.html#demangler

__cxa_demangle is defined in the header file cxxabi.h. Perhaps at build-time, bjam should check for the existence of this header file.

by Michel MORIN <mimomorin@…>, 11 years ago

Attachment: units_detail_utility.patch added

A patch for boost/units/detail/utility.hpp (against trunk r73307).

comment:2 by Michel MORIN <mimomorin@…>, 11 years ago

Owner: changed from Matthias Schabel to Steven Watanabe

Attached a patch that enables to use abi::__cxa_demangle in libc++ (though I don't fully understand the OP's problem).

in reply to:  2 comment:3 by Michel MORIN <mimomorin@…>, 11 years ago

Attached a patch that enables to use abi::__cxa_demangle in libc++

This is a wrong patch. libc++ does not provide __cxa_demangle (and cxxabi.h); it's libc++abi that provides them. I withdraw the patch.

In Mac OS X, to build libc++, libc++abi is needed (libc++abi is dynamically linked to libc++ and its symbols are re-exported). So using libc++ in Mac OS X implies that the functionality of libc++abi is also available.

#if defined(__GLIBCXX__) || defined(__GLIBCPP__) || (defined(_LIBCPP_VERSION) && defined(__APPLE__))

can detect this environment (and I locally use this code).

Sorry for the noise.

by Michel MORIN <mimomorin@…>, 11 years ago

A new patch for boost/units/detail/utility.hpp. This patch enables to detect <cxxabi.h> header file when compiling with clang.

in reply to:  1 comment:4 by Michel MORIN <mimomorin@…>, 11 years ago

comment:1

__cxa_demangle is defined in the header file cxxabi.h. Perhaps at build-time, bjam should check for the existence of this header file.

I made a new patch along this line (but the check is done at the compile-time, not at the build-time). Clang has __has_include macro that can detect a specified header file. So this check can be done at the compile-time when compiling with clang.

I tested the patch on gcc 4.3-4.6 and clang TOT (with libstdc++ and libc++) in both C++03 and C++0x modes. boost::units::detail::demangle works fine on them.

comment:5 by Michel Morin, 11 years ago

I created a new ticket #6773 (with a cleaned up patch), since my patch does not try to resolve OP's request.

comment:6 by Andrey Semashev, 8 years ago

I believe the ticket can be closed as soon as #10116 is closed.

comment:7 by Jürgen Hunold, 8 years ago

Owner: changed from Steven Watanabe to Jürgen Hunold
Status: newassigned

comment:8 by Jürgen Hunold, 8 years ago

Milestone: To Be DeterminedBoost 1.57.0
Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.