public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/48698] New: gnu-versioned-namespace problems
@ 2011-04-20 10:31 redi at gcc dot gnu.org
  2011-04-20 10:33 ` [Bug libstdc++/48698] " redi at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2011-04-20 10:31 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48698

           Summary: gnu-versioned-namespace problems
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: redi@gcc.gnu.org
                CC: bkoz@gcc.gnu.org


Bootstrap fails with errors like:

/tmp/b/x86_64-unknown-linux-gnu/libstdc++-v3/include/cwchar: In function
'wchar_t* std::_6::wcschr(wchar_t*, wchar_t)':
/tmp/b/x86_64-unknown-linux-gnu/libstdc++-v3/include/cwchar:215:55: error:
invalid conversion from 'const wchar_t*' to 'wchar_t*' [-fpermissive]
/tmp/b/x86_64-unknown-linux-gnu/libstdc++-v3/include/cwchar:214:3: error:  
initializing argument 1 of 'wchar_t* std::_6::wcschr(wchar_t*, wchar_t)'
[-fpermissive]

This is because the using declaration for ::wcschr is not in the versioned
namespace, so name lookup inside the versioned namespace finds the declaration
there and doesn't look in the enclosing namespace.

Fixed by:

--- include/c_global/cwchar     2011-04-20 10:09:58.580607848 +0000
+++ include/c_global/cwchar     2011-04-20 10:11:39.348231280 +0000
@@ -136,6 +136,8 @@

 namespace std _GLIBCXX_VISIBILITY(default)
 {
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
   using ::wint_t;

   using ::btowc;
@@ -207,8 +209,6 @@
   using ::wcsstr;
   using ::wmemchr;

-_GLIBCXX_BEGIN_NAMESPACE_VERSION
-
 #ifndef __CORRECT_ISO_CPP_WCHAR_H_PROTO
   inline wchar_t*
   wcschr(wchar_t* __p, wchar_t __c)



That allows the bootstrap to finish, but the choice of "_6" as the inline
namespace means we cannot compile this valid program or it's C++0x equivalent:

#include <tr1/functional>

int f(int i);

int g()
{
    std::tr1::bind(f, std::tr1::placeholders::_6);
}

b.cc: In function 'int g()':
b.cc:7:49: error: expected primary-expression before ')' token


The problem is that "std::tr1::placeholders::_6" is a namespace not a bind
placeholder

// Inline namespace for symbol versioning.
#if _GLIBCXX_INLINE_VERSION
namespace std
{
...
  namespace tr1
  {
    ...
    namespace placeholders { inline namespace _6 { } }
    ...
  }
  ...
  namespace placeholders { inline namespace _6 { } }


This won't work, placeholders::_6 is required to be a bind placeholder so can't
be a namespace.

It might be better to use _v6 although that would fail if users say
#define _v6 bleurgh
which is allowed.
The inline namespaces should really use a name resperved for the impl, such as
__6 or __v6


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-10-05 23:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-20 10:31 [Bug libstdc++/48698] New: gnu-versioned-namespace problems redi at gcc dot gnu.org
2011-04-20 10:33 ` [Bug libstdc++/48698] " redi at gcc dot gnu.org
2011-09-23  7:27 ` bkoz at gcc dot gnu.org
2011-09-27  0:38 ` bkoz at gcc dot gnu.org
2011-10-05 23:10 ` bkoz at gcc dot gnu.org
2011-10-05 23:12 ` bkoz at gcc dot gnu.org
2011-10-05 23:13 ` bkoz at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).