[libcxx] r176640 - Albert Wong: definition for regex_traits<_CharT>::__regex_word.

Albert Wong (王重傑) ajwong at google.com
Thu Mar 7 12:31:34 PST 2013


My understanding was that static data members needed to be defined, even if
they are integral types that are initialized with a constant expression
with an exception being made if they are not "odr-used."  (See
[class.static.data]p3)

I don't 100% understand odr-used but I think __regex_word's usage in a
non-const expression at line 1205 means this it needs to be defined and not
just declared.

As for making a test for this...it'd probably be difficult to write one
that was guaranteed to fail.  In the specific failure that prompted this,
the MIPS g++ somehow ended up with an unresolved symbol.  Oddly enough, the
ARM and x86 variants of the same compiler version didn't do this.

-Albert



On Thu, Mar 7, 2013 at 11:56 AM, Howard Hinnant <hhinnant at apple.com> wrote:

> I don't have one.  In order for me to detect this I would have to take the
> address of __regex_word, and to the best I've been able to tell, on Apple
> platforms libc++ never does this.  However Albert Wong reported errors on
> MIPS Android which this addition fixed.  I did run the regex tests on OS X
> before and after this addition and they all passed.  I view this addition
> as benign on Apple platforms, and happy to help out on MIPS Android.
>
> Howard
>
> On Mar 7, 2013, at 2:47 PM, David Blaikie <dblaikie at gmail.com> wrote:
>
> > Is there a test case to go with this?
> >
> > On Thu, Mar 7, 2013 at 11:38 AM, Howard Hinnant <hhinnant at apple.com>
> wrote:
> >> Author: hhinnant
> >> Date: Thu Mar  7 13:38:08 2013
> >> New Revision: 176640
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=176640&view=rev
> >> Log:
> >> Albert Wong: definition for regex_traits<_CharT>::__regex_word.
> >>
> >> Modified:
> >>   libcxx/trunk/include/regex
> >>
> >> Modified: libcxx/trunk/include/regex
> >> URL:
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/regex?rev=176640&r1=176639&r2=176640&view=diff
> >>
> ==============================================================================
> >> --- libcxx/trunk/include/regex (original)
> >> +++ libcxx/trunk/include/regex Thu Mar  7 13:38:08 2013
> >> @@ -1009,6 +1009,10 @@ private:
> >> };
> >>
> >> template <class _CharT>
> >> +const typename regex_traits<_CharT>::char_class_type
> >> +regex_traits<_CharT>::__regex_word;
> >> +
> >> +template <class _CharT>
> >> regex_traits<_CharT>::regex_traits()
> >> {
> >>    __init();
> >>
> >>
> >> _______________________________________________
> >> cfe-commits mailing list
> >> cfe-commits at cs.uiuc.edu
> >> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130307/efa8b635/attachment.html>


More information about the cfe-commits mailing list