[libcxx] r176640 - Albert Wong: definition for regex_traits<_CharT>::__regex_word.
David Blaikie
dblaikie at gmail.com
Thu Mar 7 12:40:57 PST 2013
On Thu, Mar 7, 2013 at 12:31 PM, Albert Wong (王重傑) <ajwong at google.com> wrote:
> 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.
In C++98 this is probably true (were you compiling in C++98 mode?). In
C++11 I don't believe this is true.
"A variable whose name appears as a potentially-evaluated expression
is odr-used unless it is an
object that satisfies the requirements for appearing in a constant
expression (5.19) and the lvalue-to-rvalue
conversion (4.1) is immediately applied"
(what this basically means, as I understand it, is: so long as you
don't need the "object" (eg: you don't take its address/want to point
to it at any time) just the value, you don't need to provide
definitions for constants)
> 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.
Do you have a MIPS bot or could contribute one? Some way to avoid
regressing things like this would be helpful for yourself & the
community.
>
> -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
>>
>
More information about the cfe-commits
mailing list