Re: std::unique_ptr, std::move, and std::forward (was Re: Using C++0x auto)

2013-07-30 Thread Brian Smith
On Wed, Jul 31, 2013 at 4:50 AM, Ehsan Akhgari wrote: > On Tue, Jul 30, 2013 at 7:40 PM, Brian Smith wrote: > >> But, shouldn't we just name these std::move and std::forward and use these >> implementations only when we're using STLPort? I know we're not supposed >> to >> add stuff to the std:: na

Re: std::unique_ptr, std::move, and std::forward (was Re: Using C++0x auto)

2013-07-30 Thread Mike Hommey
On Tue, Jul 30, 2013 at 10:50:39PM -0400, Ehsan Akhgari wrote: > On Tue, Jul 30, 2013 at 7:40 PM, Brian Smith > wrote: > > > On Fri, Jul 19, 2013 at 4:46 AM, Mike Hommey > > wrote: > > > > > Note that STL is another story. We're not using libstdc++ that > > > comes with the compiler on android a

Re: std::unique_ptr, std::move, and std::forward (was Re: Using C++0x auto)

2013-07-30 Thread Ehsan Akhgari
On Tue, Jul 30, 2013 at 7:40 PM, Brian Smith wrote: > On Fri, Jul 19, 2013 at 4:46 AM, Mike Hommey wrote: > > > Note that STL is another story. We're not using libstdc++ that comes > > with the compiler on android and b2g. We use STLport instead, and STLport > > has, afaik, no support for C++11

std::unique_ptr, std::move, and std::forward (was Re: Using C++0x auto)

2013-07-30 Thread Brian Smith
On Fri, Jul 19, 2013 at 4:46 AM, Mike Hommey wrote: > Note that STL is another story. We're not using libstdc++ that comes > with the compiler on android and b2g. We use STLport instead, and STLport > has, afaik, no support for C++11 STL types. So, while we can now fix > nsAutoPtr to use move sem

Re: Using C++0x auto

2013-07-23 Thread Benjamin Smedberg
On 7/22/2013 6:05 PM, Rob Arnold wrote: Ah, you're right. Bad example. 'UseFoo(new T)' compiles but leaks, 'nsRefPtr foo() { nsRefPtr bar(...); ...; return bar; }' is a use-after-tree in cases like 'T* p = foo();' and there are probably a number of other cases that the compiler allows and/or wri

Re: Using C++0x auto

2013-07-23 Thread Aryeh Gregor
On Mon, Jul 22, 2013 at 10:01 PM, Rob Arnold wrote: > That idiom seems dangerous by itself; the assumption it makes is that the > reference will outlive the callee but that isn't actually enforced anywhere > (you could write UseFoo(nsRefPtr(new T)) and Bad Things would happen; > there are less obv

Re: Using C++0x auto

2013-07-22 Thread Rob Arnold
On Mon, Jul 22, 2013 at 12:46 PM, Benjamin Smedberg wrote: > On 7/22/2013 3:01 PM, Rob Arnold wrote: > >> >> Wouldn't disallowing this implicit conversion break code which does >> >>void UseFoo(nsIFoo* foo); >> >>nsCOMPtr foo; >>UseFoo(foo); >> >> ? That is an extremely common idiom i

Re: Using C++0x auto

2013-07-22 Thread Benjamin Smedberg
On 7/22/2013 3:01 PM, Rob Arnold wrote: Wouldn't disallowing this implicit conversion break code which does void UseFoo(nsIFoo* foo); nsCOMPtr foo; UseFoo(foo); ? That is an extremely common idiom in our code. That idiom seems dangerous by itself; the assumption it makes is that th

Re: Using C++0x auto

2013-07-22 Thread Joshua Cranmer 🐧
On 7/22/2013 1:59 AM, Justin Lebar wrote: It seems really dangerous that there is an implicit conversion from a strong ref ptr to a weak pointer. With C++11, you can thankfully require this conversion to be explicit which should alleviate your concern. Wouldn't disallowing this implicit conversi

Re: Using C++0x auto

2013-07-22 Thread Ralph Giles
On 13-07-22 10:30 AM, Ehsan Akhgari wrote: > That's not possible in C++11. Thinking about this more, the reason that > this works fine for std::shared_ptr is the fact that it does _not_ have > a T* implicit conversion operator. Therefore, we can't switch to rvalue > references to replace already_

Re: Using C++0x auto

2013-07-22 Thread Rob Arnold
On Sun, Jul 21, 2013 at 11:59 PM, Justin Lebar wrote: > > It seems really dangerous that there is an implicit conversion from a > strong > > ref ptr to a weak pointer. With C++11, you can thankfully require this > > conversion to be explicit which should alleviate your concern. > > Wouldn't disall

Re: Using C++0x auto

2013-07-22 Thread Ehsan Akhgari
On 2013-07-22 2:59 AM, Justin Lebar wrote: It seems really dangerous that there is an implicit conversion from a strong ref ptr to a weak pointer. With C++11, you can thankfully require this conversion to be explicit which should alleviate your concern. Wouldn't disallowing this implicit conver

Re: Using C++0x auto

2013-07-22 Thread Benjamin Smedberg
On 7/22/2013 4:40 AM, Neil wrote: Robert O'Callahan wrote: On Mon, Jul 22, 2013 at 3:58 PM, L. David Baron wrote: Is the idea here that nsRefPtr/nsCOMPtr/etc. would have move constructors, and we'd just return them, and the move constructors plus return value optimizations would take care

Re: Using C++0x auto

2013-07-22 Thread Neil
Robert O'Callahan wrote: On Mon, Jul 22, 2013 at 3:58 PM, L. David Baron wrote: Is the idea here that nsRefPtr/nsCOMPtr/etc. would have move constructors, and we'd just return them, and the move constructors plus return value optimizations would take care of avoiding excess reference counti

Re: Using C++0x auto

2013-07-22 Thread Justin Lebar
> It seems really dangerous that there is an implicit conversion from a strong > ref ptr to a weak pointer. With C++11, you can thankfully require this > conversion to be explicit which should alleviate your concern. Wouldn't disallowing this implicit conversion break code which does void UseFo

Re: Using C++0x auto

2013-07-21 Thread Rob Arnold
On Sun, Jul 21, 2013 at 10:39 PM, Justin Lebar wrote: > AIUI the new constructor would be something like > > nsRefPtr(nsRefPtr&& aOther) > > where "&&" means "r-value", which means "temporary", so "moveable". > Yes, this is why you want to be careful when returning them. The rules should be mor

Re: Using C++0x auto

2013-07-21 Thread Robert O'Callahan
On Mon, Jul 22, 2013 at 5:39 PM, Justin Lebar wrote: > But if we return nsRefPtr, then if I have > > nsRefPtr GetFoo(); > Foo* = GetFoo(); > > that compiles fine (I think?) because nsRefPtr has an implicit > conversion to T*. > It doesn't leak, though. OTOH you probably get a use-after-free,

Re: Using C++0x auto

2013-07-21 Thread Justin Lebar
AIUI the new constructor would be something like nsRefPtr(nsRefPtr&& aOther) where "&&" means "r-value", which means "temporary", so "moveable". But I'm not totally sure about being able to return nsRefPtr. Right now, if I do already_AddRefed GetFoo(); Foo* foo = GetFoo(); that's a comp

Re: Using C++0x auto

2013-07-21 Thread Robert O'Callahan
On Mon, Jul 22, 2013 at 3:58 PM, L. David Baron wrote: > Is the idea here that nsRefPtr/nsCOMPtr/etc. would have move > constructors, and we'd just return them, and the move constructors > plus return value optimizations would take care of avoiding excess > reference counting? > That, plus forge

Re: Using C++0x auto

2013-07-21 Thread L. David Baron
On Friday 2013-07-19 12:15 +1200, Robert O'Callahan wrote: > On Fri, Jul 19, 2013 at 3:34 AM, Ehsan Akhgari wrote: > > > On 2013-07-18 5:48 AM, mscl...@googlemail.com wrote: > > > > r-value references 4.3@10.0! Yes > >> > > > > This is very useful. I believe the JS engine alre

Re: Using C++0x auto

2013-07-21 Thread Jeff Walden
On 07/21/2013 11:44 AM, Justin Lebar wrote: > That's a fair point. Maybe we should call ours mozilla::Move and > mozilla::Forward instead. That way we can still easily change them to > std::move and std::forward, but there's no possibility of a collision. This is pretty much always what we've do

Re: Using C++0x auto

2013-07-21 Thread Justin Lebar
>> Maybe we should call ours mozilla::move and mozilla::forward so that we >> can change to std::move and std::forward with minimal pain? >> > Won't that cause confusion if someone accidentally has both using namespace > mozilla; and using namespace std; at the same time? That's a fair point. May

Re: Using C++0x auto

2013-07-21 Thread Gabriele Svelto
On 21/07/2013 17:56, Neil wrote: Won't that cause confusion if someone accidentally has both using namespace mozilla; and using namespace std; at the same time? Possibly but our coding guidelines suggest that we avoid using ...; statements preferring to wrap code into namespace ... { ... }; c

Re: Using C++0x auto

2013-07-21 Thread Neil
Justin Lebar wrote: Maybe we should call ours mozilla::move and mozilla::forward so that we can change to std::move and std::forward with minimal pain? Won't that cause confusion if someone accidentally has both using namespace mozilla; and using namespace std; at the same time? -- Warning:

Re: Using C++0x auto

2013-07-19 Thread Justin Lebar
Maybe we should call ours mozilla::move and mozilla::forward so that we can change to std::move and std::forward with minimal pain? On Jul 19, 2013 4:36 PM, "Ehsan Akhgari" wrote: > On 2013-07-19 7:04 PM, Mike Hommey wrote: > >> On Fri, Jul 19, 2013 at 03:45:13PM -0400, Ehsan Akhgari wrote: >> >>

Re: Using C++0x auto

2013-07-19 Thread Ehsan Akhgari
On 2013-07-19 7:04 PM, Mike Hommey wrote: On Fri, Jul 19, 2013 at 03:45:13PM -0400, Ehsan Akhgari wrote: On 2013-07-19 3:26 PM, Ehsan Akhgari wrote: On 2013-07-18 10:46 PM, Mike Hommey wrote: On Thu, Jul 18, 2013 at 08:54:02PM -0500, Joshua Cranmer ? wrote: On 7/18/2013 7:15 PM, Robert O'Call

Re: Using C++0x auto

2013-07-19 Thread Mike Hommey
On Fri, Jul 19, 2013 at 03:45:13PM -0400, Ehsan Akhgari wrote: > On 2013-07-19 3:26 PM, Ehsan Akhgari wrote: > >On 2013-07-18 10:46 PM, Mike Hommey wrote: > >>On Thu, Jul 18, 2013 at 08:54:02PM -0500, Joshua Cranmer ? wrote: > >>>On 7/18/2013 7:15 PM, Robert O'Callahan wrote: > On Fri, Jul 19,

Re: Using C++0x auto

2013-07-19 Thread Ehsan Akhgari
On 2013-07-19 3:26 PM, Ehsan Akhgari wrote: On 2013-07-18 10:46 PM, Mike Hommey wrote: On Thu, Jul 18, 2013 at 08:54:02PM -0500, Joshua Cranmer ? wrote: On 7/18/2013 7:15 PM, Robert O'Callahan wrote: On Fri, Jul 19, 2013 at 3:34 AM, Ehsan Akhgari wrote: On 2013-07-18 5:48 AM, mscl...@googlem

Re: Using C++0x auto

2013-07-19 Thread Ehsan Akhgari
On 2013-07-18 10:46 PM, Mike Hommey wrote: On Thu, Jul 18, 2013 at 08:54:02PM -0500, Joshua Cranmer ? wrote: On 7/18/2013 7:15 PM, Robert O'Callahan wrote: On Fri, Jul 19, 2013 at 3:34 AM, Ehsan Akhgari wrote: On 2013-07-18 5:48 AM, mscl...@googlemail.com wrote: r-value references

Re: Using C++0x auto

2013-07-18 Thread Mike Hommey
On Thu, Jul 18, 2013 at 08:54:02PM -0500, Joshua Cranmer ? wrote: > On 7/18/2013 7:15 PM, Robert O'Callahan wrote: > >On Fri, Jul 19, 2013 at 3:34 AM, Ehsan Akhgari > >wrote: > > > >>On 2013-07-18 5:48 AM, mscl...@googlemail.com wrote: > >> > >> r-value references 4.3@10.0! Yes

Re: Using C++0x auto

2013-07-18 Thread Joshua Cranmer 🐧
On 7/18/2013 7:15 PM, Robert O'Callahan wrote: On Fri, Jul 19, 2013 at 3:34 AM, Ehsan Akhgari wrote: On 2013-07-18 5:48 AM, mscl...@googlemail.com wrote: r-value references 4.3@10.0! Yes This is very useful. I believe the JS engine already rolls their own tricks to implem

Re: Using C++0x auto

2013-07-18 Thread Mike Hommey
On Thu, Jul 18, 2013 at 11:34:53AM -0400, Ehsan Akhgari wrote: > On 2013-07-18 5:48 AM, mscl...@googlemail.com wrote: > > From that table, using the gcc and msvc versions, that gives: > > > > gcc msvcclang auto 4.4 10.0* > > Yes > >

Re: Using C++0x auto

2013-07-18 Thread Robert O'Callahan
On Fri, Jul 19, 2013 at 3:34 AM, Ehsan Akhgari wrote: > On 2013-07-18 5:48 AM, mscl...@googlemail.com wrote: > > r-value references 4.3@10.0! Yes >> > > This is very useful. I believe the JS engine already rolls their own > tricks to implement this semantics. > With this we c

Re: Using C++0x auto

2013-07-18 Thread Ehsan Akhgari
On 2013-07-18 5:48 AM, mscl...@googlemail.com wrote: From that table, using the gcc and msvc versions, that gives: gcc msvcclang auto4.4 10.0* Yes Yes, please! decltype4.3@10.0@ 2.9 Yes

Re: Using C++0x auto

2013-07-18 Thread Ehsan Akhgari
On 2013-07-18 10:49 AM, Joshua Cranmer 🐧 wrote: On 7/18/2013 9:44 AM, Ehsan Akhgari wrote: On 2013-07-18 5:32 AM, Mike Hommey wrote: A good resource is http://wiki.apache.org/stdcxx/C++0xCompilerSupport Our base versions are 4.4 for gcc, and 10.0 for MSVC. I'm not sure what our lowest supported

Re: Using C++0x auto

2013-07-18 Thread Joshua Cranmer 🐧
On 7/18/2013 9:44 AM, Ehsan Akhgari wrote: On 2013-07-18 5:32 AM, Mike Hommey wrote: A good resource is http://wiki.apache.org/stdcxx/C++0xCompilerSupport Our base versions are 4.4 for gcc, and 10.0 for MSVC. I'm not sure what our lowest supported version of clang is. As of bug 870173, it's 3.

Re: Using C++0x auto

2013-07-18 Thread Ehsan Akhgari
On 2013-07-18 5:32 AM, Mike Hommey wrote: On Wed, Jul 17, 2013 at 05:09:22PM +0900, Mike Hommey wrote: On Tue, Jul 16, 2013 at 04:17:50PM +0900, Mike Hommey wrote: On Sat, Jul 13, 2013 at 01:15:31PM -0700, Kyle Huey wrote: We've dropped support for versions of MSVC prior to 2010, and we're req

Re: Using C++0x auto

2013-07-18 Thread Joshua Cranmer 🐧
On 7/18/2013 4:32 AM, Mike Hommey wrote: And it's now done. Thanks to Ted Mielczarek and Ben Hearsum for the quick reviews, and Aki Sasaki for the buildbot reconfig. Now we can start discussing what specific features we want to start using. Bug 895322 has already been filed to use static_assert

Re: Using C++0x auto

2013-07-18 Thread msclrhd
On Thursday, 18 July 2013 10:32:35 UTC+1, Mike Hommey wrote: > On Wed, Jul 17, 2013 at 05:09:22PM +0900, Mike Hommey wrote: > > > On Tue, Jul 16, 2013 at 04:17:50PM +0900, Mike Hommey wrote: > > > > On Sat, Jul 13, 2013 at 01:15:31PM -0700, Kyle Huey wrote: > > > > > We've dropped support for v

Re: Using C++0x auto

2013-07-18 Thread Mike Hommey
On Wed, Jul 17, 2013 at 05:09:22PM +0900, Mike Hommey wrote: > On Tue, Jul 16, 2013 at 04:17:50PM +0900, Mike Hommey wrote: > > On Sat, Jul 13, 2013 at 01:15:31PM -0700, Kyle Huey wrote: > > > We've dropped support for versions of MSVC prior to 2010, and > > > we're requiring at least GCC 4.4. Acc

Re: Using C++0x auto

2013-07-17 Thread Mike Hommey
On Tue, Jul 16, 2013 at 04:17:50PM +0900, Mike Hommey wrote: > On Sat, Jul 13, 2013 at 01:15:31PM -0700, Kyle Huey wrote: > > We've dropped support for versions of MSVC prior to 2010, and we're > > requiring at least GCC 4.4. According to [0] that means we should > > be able to use *auto*. Anybod

Re: Using C++0x auto

2013-07-16 Thread Mike Hommey
On Sat, Jul 13, 2013 at 01:15:31PM -0700, Kyle Huey wrote: > We've dropped support for versions of MSVC prior to 2010, and we're > requiring at least GCC 4.4. According to [0] that means we should be > able to use *auto*. Anybody know any reasons why we can't start using > it? Filed bug 894242.

Re: Using C++0x auto

2013-07-15 Thread Mike Hommey
On Sun, Jul 14, 2013 at 10:50:55PM -0700, Justin Lebar wrote: > > We can't require any c++11 feature until we drop support for gcc > > 4.4. [...] there are problems in the gcc 4.4 system headers that > > make using c++11 mode impossible (except on b2g/android). > > Is there any reason to support

Re: Using C++0x auto

2013-07-15 Thread Chris Peterson
On 7/14/13 10:50 PM, Justin Lebar wrote: >We can't require any c++11 feature until we drop support for gcc 4.4. >[...] there are problems in the gcc 4.4 system headers that make using c++11 mode impossible (except on b2g/android). Is there any reason to support gcc 4.4 outside of B2G/Android?

Re: Using C++0x auto

2013-07-15 Thread Joshua Cranmer
On 7/13/2013 3:15 PM, Kyle Huey wrote: We've dropped support for versions of MSVC prior to 2010, and we're requiring at least GCC 4.4. According to [0] that means we should be able to use /auto/. Anybody know any reasons why we can't start using it? We don't yet require C++11 mode when build

Re: Using C++0x auto

2013-07-14 Thread Justin Lebar
> We can't require any c++11 feature until we drop support for gcc 4.4. > [...] there are problems in the gcc 4.4 system headers that make using c++11 > mode impossible (except on b2g/android). Is there any reason to support gcc 4.4 outside of B2G/Android? If we dropped support for gcc 4.4 on de

Re: Using C++0x auto

2013-07-13 Thread Mike Hommey
On Sat, Jul 13, 2013 at 01:15:31PM -0700, Kyle Huey wrote: > We've dropped support for versions of MSVC prior to 2010, and we're > requiring at least GCC 4.4. According to [0] that means we should be able > to use *auto*. Anybody know any reasons why we can't start using it? We can't require any