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

            Bug ID: 60987
           Summary: libstdc++ header file tr1/regex causes clang++
                    compilation error
           Product: gcc
           Version: 4.10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bergner at gcc dot gnu.org

It seems clang++ is more pedantic on the syntax it accepts for initializing
arrays of strings.  The tr1/regex header file (gcc 4.6 thru trunk) contains an
array initialization that clang++ doesn't accept, but g++ does:

bergner@bns:~> cat bug.cc 
#include <tr1/regex>

bergner@bns:~> /home/bergner/llvm/llvm-install/bin/clang++ -c bug.cc 
In file included from bug.cc:1:
/home/bergner/gcc/install/gcc-fsf-mainline-build/include/c++/4.10.0/tr1:685:24:
error: array
      initializer must be an initializer list
            const char* const __wb[] = "w";
                              ^
/home/bergner/gcc/install/gcc-fsf-mainline-build/include/c++/4.10.0/tr1:695:24:
error: array
      initializer must be an initializer list
            const char* const __bb[] = "blank";
                              ^
2 errors generated.

The following patch is enough to quiet the clang++ error messages:

Index: libstdc++-v3/include/tr1/regex
===================================================================
--- libstdc++-v3/include/tr1/regex    (revision 209382)
+++ libstdc++-v3/include/tr1/regex    (working copy)
@@ -682,7 +682,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       // special case of underscore in [[:w:]]
       if (__c == __ctype.widen('_'))
     {
-      const char* const __wb[] = "w";
+      const char* const __wb[] = {"w"};
       char_class_type __wt = this->lookup_classname(__wb,
                             __wb + sizeof(__wb));
       if (__f | __wt)
@@ -692,7 +692,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       // special case of [[:space:]] in [[:blank:]]
       if (__c == __ctype.isspace(__c))
     {
-      const char* const __bb[] = "blank";
+      const char* const __bb[] = {"blank"};
       char_class_type __bt = this->lookup_classname(__bb,
                             __bb + sizeof(__bb));
       if (__f | __bt)

Reply via email to