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 13662 - Erroneous visibility error, or a problem in libc++
Summary: Erroneous visibility error, or a problem in libc++
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: C++ (show other bugs)
Version: trunk
Hardware: All All
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-22 07:28 PDT by Dimitry Andric
Modified: 2012-08-22 09:53 PDT (History)
4 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 Dimitry Andric 2012-08-22 07:28:38 PDT
For the following:

  #pragma GCC visibility push(hidden)
  template<class T> class __attribute__((__visibility__("default"))) foo;
  class bar { template<class T> friend class foo; };

clang emits the following error:

  t.cpp:1:13: error: visibility does not match previous declaration
  #pragma GCC visibility push(hidden)
	      ^
  t.cpp:2:40: note: previous attribute is here
  template<class T> class __attribute__((__visibility__("default"))) foo;
					 ^
  1 error generated.

Not only does the error point to the incorrect location (see bug 13658),
but it also seems to be wrong.  At least, r160105 doesn't complain about
it, while r160495 does (I'm still bisecting).

The sample has been reduced from the following, something which Firefox
apparently does, and which now doesn't work with libc++:

  #pragma GCC visibility push(hidden)
  #include <iterator>

In libc++ <iterator>, it first includes at least one forward declaration
of basic_string with a default visibility attribute, and then follows:

  template <class _Iter>
  class __wrap_iter
  {
  ...
      template <class _CharT, class _Traits, class _Alloc> friend class basic_string;

And this now causes an error with clang trunk.
Comment 1 Dimitry Andric 2012-08-22 07:35:09 PDT
Note also that the testcase with the templates removed, e.g.:

  #pragma GCC visibility push(hidden)
  class __attribute__((__visibility__("default"))) foo;
  class bar { friend class foo; };

compiles without error.  Apparently the visibility isn't a problem
then...
Comment 2 Rafael Ávila de Espíndola 2012-08-22 08:20:43 PDT
I will take a look.
Comment 3 Rafael Ávila de Espíndola 2012-08-22 09:53:18 PDT
Fixed in r162360.