tag:blogger.com,1999:blog-7101933101966798446.post1291856493955652600..comments2024-03-28T10:33:06.910-07:00Comments on The View from Aristeia: C++11 is Almost Here for Real!Scott Meyershttp://www.blogger.com/profile/05280964633768289328noreply@blogger.comBlogger25125tag:blogger.com,1999:blog-7101933101966798446.post-25205171320510402822012-12-01T21:55:55.281-08:002012-12-01T21:55:55.281-08:00GCC printf warning bug should be fixed as of 4.8:
...GCC printf warning bug should be fixed as of 4.8:<br />http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52818Kenny Simpsonhttps://www.blogger.com/profile/00272386428117352209noreply@blogger.comtag:blogger.com,1999:blog-7101933101966798446.post-66361237493121316332012-10-05T00:03:41.897-07:002012-10-05T00:03:41.897-07:00This comment has been removed by a blog administrator.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7101933101966798446.post-50217335866558308262012-10-05T00:02:22.259-07:002012-10-05T00:02:22.259-07:00It compiled with clang (svn3.2) and libc++ (and pr...It compiled with clang (svn3.2) and libc++ (and probably has for a long time; I don't see any C++11 features that haven't been in clang for a long time now).<br /><br />It also appears to run fine unless I build using -fcatch-undefined-behavior. Running the program built with that flag indicates that there's some kind of undefined behavior in the program. The output doesn't give any hints as to the cause though. I understand some work is being done to improve that so maybe more info will be available soon.Sethhttps://www.blogger.com/profile/17431137932397580532noreply@blogger.comtag:blogger.com,1999:blog-7101933101966798446.post-75341252897729038872012-08-12T02:22:01.975-07:002012-08-12T02:22:01.975-07:00BTW, rather than testing with gcc under windows - ...BTW, rather than testing with gcc under windows - which I have found to be a pain, there are some great free-to-use virtualisation programs like virtualbox.org.<br /><br />Virtualisation lets you install linux for just such demos and tests even though you have a windows computer.<br /><br />1) Install virtualbox from virtualbox.org (< 5 mins with high-speed corporate internet)<br />2) Install Ubuntu from ubuntu.com (< 30 mins)<br />3) sudo apt-get install g++ (< 5 mins) - for the latest g++ that version of ubuntu has<br />3a) follow the build instructions for gcc and apt-get install any prerequisites for the latest full gcc/g++ version (3 hours)<br /><br />You will then have a Linux desktop ready to compile using a full version of g++ in a window on your windows machine (pretty cool - you really ought to try this technology out).Anonymoushttps://www.blogger.com/profile/01446359502937021335noreply@blogger.comtag:blogger.com,1999:blog-7101933101966798446.post-3299694581471237622012-08-08T01:20:53.649-07:002012-08-08T01:20:53.649-07:00Compiles and works fine on my MacBook Pro OSX Lion...Compiles and works fine on my MacBook Pro OSX Lion using gcc-4.7.0 :)<br /><br />>: g++ --version<br />g++ (GCC) 4.7.0<br />Copyright (C) 2012 Free Software Foundation, Inc.<br />This is free software; see the source for copying conditions. There is NO<br />warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.<br /><br />>: g++ -std=c++11 myers.cpp -o myers<br />>: ./myers myers.cpp<br />155 words found. Most common:<br /> // 13<br /> #include 9<br /> { 8<br /> } 8<br /> for 7<br /> = 7<br /> const 5<br /> return 4<br /> WordCountMapType 4<br /> wordCounts; 3<br /> words 3<br /> of 2<br /> : 2<br /> << 2<br /> std::vector 2<br /> most 2<br /> it 2<br /> in 2<br /> common 2<br /> != 2<br /><br />AS I remember it compiling gcc 470 on my mac was hard because apple ship LLVM based gcc with Xcode 4. I'll build 4.7.1 and see if it still works.Phil Paynenoreply@blogger.comtag:blogger.com,1999:blog-7101933101966798446.post-91932018632490711982012-04-23T10:00:04.137-07:002012-04-23T10:00:04.137-07:00it compiles with -Wall -Wextra and runs correctly ...it compiles with -Wall -Wextra and runs correctly with gcc-4.7.0 (built from source) on os/x 10.7.3, both 32 and 64.dxcnoreply@blogger.comtag:blogger.com,1999:blog-7101933101966798446.post-80724853376600296992012-04-19T11:04:14.402-07:002012-04-19T11:04:14.402-07:00@Scott
Thanks very much Scott for answering my c...@Scott <br /><br />Thanks very much Scott for answering my cheekily posted questions. I am now on packaged_task and looking at opportunities there. The videos http://www.youtube.com/watch?v=80ifzK3b8QQ&feature=relmfu by Bartosz are very much worth a watch for anyone interested in c++11 concurrency support, plus of course Anthony Williams blog. <br /><br />Can I just add great books Scott!! all our developers get at least Effective c++ and more Effective c++ on their desk when starting with us. They are excellent, I keenly await the c++11 version, although I think this will take a load of time to find all the nuances there to keep to your high standards.Anonymoushttps://www.blogger.com/profile/12664084316556539778noreply@blogger.comtag:blogger.com,1999:blog-7101933101966798446.post-24583248477569408132012-04-13T08:38:48.423-07:002012-04-13T08:38:48.423-07:00@David:
1. By default, async may choose whether ...@David: <br /><br />1. By default, async may choose whether to run its function synchronously or asynchronously, the idea being to give it the flexibility to avoid oversubscription. If you want to guarantee that the function passed to std::async will run asychronously, you need to specify a launch policy of std::launch::async.<br /><br />2. The standard gives no guarantees about thread pools or efficient use of threads or scheduling fairness, etc. All that is considered QoI (Quality of Implementation) stuff. It's reasonable to assume that once implementers have the basic functionality under control, they will turn their attention to QoI issues. <a href="http://blog.corensic.com/2011/10/10/async-tasks-in-c11-not-quite-there-yet/" rel="nofollow">Bartosz Milewski's blog post from last October</a> is worth reading in this regard. <br /><br />ScottScott Meyershttps://www.blogger.com/profile/05280964633768289328noreply@blogger.comtag:blogger.com,1999:blog-7101933101966798446.post-30909236503693989712012-04-13T07:24:31.574-07:002012-04-13T07:24:31.574-07:00gcc 4.6 is perfectly fine as well. Needs the using...gcc 4.6 is perfectly fine as well. Needs the using changed to a typedef as MSVC11Beta apparently. <br /><br />Output below. I would like to ask a sneaky wee question if possible (I bought the c++11 overview, very good, no enough grovelling). Could you tell me if <br /><br />1: Will std::async launch automatically in async mode or do we need to make sure by passing a launch to it (std::launch::async) ? <br /><br />2: Are there any thread pool policies compilers should be expected to follow, i.e. do I need to worry about thread pools/efficient reuse etc.?<br /><br />(I did read where you say we need to care about cleaning up thread local storage objects and that's OK) <br /><br /><br />~/ggcov-0.8.3 $ gcc --version<br />gcc (Ubuntu/Linaro 4.6.3-1ubuntu4) 4.6.3<br />Copyright (C) 2011 Free Software Foundation, Inc.<br />This is free software; see the source for copying conditions. There is NO<br />warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE<br /><br /><b>g++ -Wall -Wextra -Weffc++ -std=c++0x -pthread d.cc</b><br /><br /><b> Output</b><br /><br />155 words found. Most common:<br /> // 13<br /> #include 9<br /> { 8<br /> } 8<br /> for 7<br /> = 6<br /> const 5<br /> return 4<br /> WordCountMapType 3<br /> typedef 3<br /> words 3<br /> wordCounts; 3<br /> i 2<br /> word; 2<br /> in 2<br /> MapIt 2<br /> it 2<br /> std::vector 2<br /> of 2<br /> auto 2Anonymoushttps://www.blogger.com/profile/12664084316556539778noreply@blogger.comtag:blogger.com,1999:blog-7101933101966798446.post-11374110294046489542012-04-07T23:25:37.740-07:002012-04-07T23:25:37.740-07:00Yep its a matter of details compared to the first ...Yep its a matter of details compared to the first time I played with gcc support for c++0x! ;)Anonymoushttps://www.blogger.com/profile/17210197569883727100noreply@blogger.comtag:blogger.com,1999:blog-7101933101966798446.post-59556948151147482312012-04-07T16:36:26.452-07:002012-04-07T16:36:26.452-07:00Regarding gcc's diagnostic, "warning: ISO...Regarding gcc's diagnostic, "warning: ISO C++ does not support the ‘z’ gnu_printf length modifier," this is incorrect as of C++11. C++11 relies on C99 for the specification for printf formatting strings, and "z" is part of C99 (in 17.6.9.1/7).<br /><br />ScottScott Meyershttps://www.blogger.com/profile/05280964633768289328noreply@blogger.comtag:blogger.com,1999:blog-7101933101966798446.post-10377182687908815852012-04-07T13:25:05.334-07:002012-04-07T13:25:05.334-07:00Adding -Wall -pedantic print this warning though:
...Adding -Wall -pedantic print this warning though:<br /><br />prog.cpp:41:5: warning: ISO C++ does not support the ‘z’ gnu_printf length modifier [-Wformat]<br /><br />I guess its just a matter of detail ;)<br /><br /> fxAnonymoushttps://www.blogger.com/profile/17210197569883727100noreply@blogger.comtag:blogger.com,1999:blog-7101933101966798446.post-69414412238235652902012-04-07T13:21:49.909-07:002012-04-07T13:21:49.909-07:00As Wojciech Cierpucha realized, pthread is not aut...As Wojciech Cierpucha realized, pthread is not automatically linked, and nothing warn about any symbol missing.<br /><br />Here the test with gcc-4.8 again, no errors, no warning, and seem to run fine:<br /><br />g++-4.8 --version<br />g++-4.8 (GCC) 4.8.0 20120311 (experimental)<br />g++-4.8 --std=c++11 -lpthread prog.cpp <br />./a.out prog.cpp <br />155 words found. Most common:<br /> // 13<br /> #include 9<br /> { 8<br /> } 8<br /> for 7<br /> = 7<br /> const 5<br /> return 4<br /> WordCountMapType 4<br /> wordCounts; 3<br /> words 3<br /> of 2<br /> : 2<br /> << 2<br /> std::vector 2<br /> most 2<br /> it 2<br /> in 2<br /> common 2<br /> != 2<br /><br />Regards,<br />fxAnonymoushttps://www.blogger.com/profile/17210197569883727100noreply@blogger.comtag:blogger.com,1999:blog-7101933101966798446.post-38683358006375214322012-04-06T12:21:32.450-07:002012-04-06T12:21:32.450-07:00It compiles on Mac with the macports g++-4.7:
g++...It compiles on Mac with the macports g++-4.7:<br /><br />g++-mp-4.7 (GCC) 4.7.0 20120225 (experimental). It runs and seems to produce the correct output.greghttps://www.blogger.com/profile/04445157434767902523noreply@blogger.comtag:blogger.com,1999:blog-7101933101966798446.post-58568600394659478572012-04-06T10:19:40.206-07:002012-04-06T10:19:40.206-07:00I've revised the title of this blog entry and ...I've revised the title of this blog entry and updated the content to reflect the fact that, on the proper platform and with the proper command line options, gcc 4.7 accepts my sample program. I'm very excited about this, and I thank Wojciech and Anonymous for letting me know about it. C++11, at least for the simple demonstration I wrote three years ago, is finally here!<br /><br />ScottScott Meyershttps://www.blogger.com/profile/05280964633768289328noreply@blogger.comtag:blogger.com,1999:blog-7101933101966798446.post-80744019356441088742012-04-06T06:41:43.087-07:002012-04-06T06:41:43.087-07:00@Scott
Sorry about that, apparently when I press ...@Scott<br /><br />Sorry about that, apparently when I press "Show Original Post" when I'm in the comment zone, I'm redirected to a version of your page without proper formatting. <br /><br />Using a direct link to your blog works perfectly:<br /><br />http://scottmeyers.blogspot.ca/2012/04/c11-is-almost-here-for-real.html<br /><br />So, I've tested your code on Mac OSX Lion and Cygwin (under Windows 7) with a custom compiled gcc-4.7.0 and it works perfectly. Here is a link to some screenshots (I'll keep them for a few days in my Dropbox folder), feel free to use them as you wish:<br /><br />https://www.dropbox.com/gallery/56297644/1/tests?h=824eb5<br /><br />PaulAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-7101933101966798446.post-442313179542952232012-04-06T02:15:16.617-07:002012-04-06T02:15:16.617-07:00It turns out one has to pass -pthread to g++ and i...It turns out one has to pass -pthread to g++ and it starts working. I hope it will be on by default when compiling in c++11 mode in the future versions of gcc.<br /><br />To sum up, your example works perfectly without any code modifications on GCC 4.7.0.Łysa Głowahttps://www.blogger.com/profile/10347052886262269341noreply@blogger.comtag:blogger.com,1999:blog-7101933101966798446.post-59398381643487566842012-04-06T01:26:39.593-07:002012-04-06T01:26:39.593-07:00It compiled on Linux with GCC 4.7.0 with only one ...It compiled on Linux with GCC 4.7.0 with only one warning:<br />warning: ISO C++ does not support the ‘z’ gnu_printf length modifier [-Wformat]<br />I've used -Wall -Wextra -pedantic -std=c++11.<br /><br />When it comes to running it, the situation changes. It works fine without any arguments, but throws an "Unknown error -1" std::system_exception if I pass some file name to it.Łysa Głowahttps://www.blogger.com/profile/10347052886262269341noreply@blogger.comtag:blogger.com,1999:blog-7101933101966798446.post-62180564358931999212012-04-05T22:19:47.274-07:002012-04-05T22:19:47.274-07:00@Anonymous: the code is between pre tags, and copy...@Anonymous: the code is between pre tags, and copying it from the blog post (either from my blog site or from the entry's version in Google Reader) using Firefox lets me paste it into a text editor with formatting intact. Are you not able to do the same thing?<br /><br />ScottScott Meyershttps://www.blogger.com/profile/05280964633768289328noreply@blogger.comtag:blogger.com,1999:blog-7101933101966798446.post-22545048277802986022012-04-05T20:01:05.831-07:002012-04-05T20:01:05.831-07:00I've used the following easy way to test thing...I've used the following easy way to test things with Linux compiler in Windows: (1) install VirtualBox, it's free, and (2) install Debian in a virtual box. The only problem I had with that was lack of built-in support for Norwegian keyboard. I found a config file on the net that fixed that, and then even copy and paste between Windows and the Lunix box worked (that is, works)! Cheers, - AlfAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-7101933101966798446.post-77861111549057926002012-04-05T18:31:29.092-07:002012-04-05T18:31:29.092-07:00Sure,
can you repost your code between pre tags o...Sure,<br /><br />can you repost your code between pre tags or some other tag that will preserve the original format ? I'll check your code on a Mac with gcc-4.7 and on Cygwin (Windows 7).<br /><br />PaulAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-7101933101966798446.post-31651964528190249572012-04-05T18:20:05.088-07:002012-04-05T18:20:05.088-07:00Can you check to see if the program I posted compi...Can you check to see if the program I posted compiles under the conditions you describe? If so, can you let me know if it seems to run properly?<br /><br />Thanks,<br /><br />ScottScott Meyershttps://www.blogger.com/profile/05280964633768289328noreply@blogger.comtag:blogger.com,1999:blog-7101933101966798446.post-70808365129168017232012-04-05T18:13:31.978-07:002012-04-05T18:13:31.978-07:00Threading support works if you compile gcc-4.7 on ...Threading support works if you compile gcc-4.7 on Cygwin and chose thread=posix.<br /><br />PaulAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-7101933101966798446.post-69261205719630382872012-04-05T17:29:41.869-07:002012-04-05T17:29:41.869-07:00So it compiles with gcc 4.8 under Linux. Cool! D...So it compiles with gcc 4.8 under Linux. Cool! Did you happen to try gcc 4.7 as well? Unfortunately, I have access only to Windows, so I can't check myself.<br /><br />If you get a chance to get some more information about the runtime failure, I'd be interested to know the details. It seems to work correctly for me under Windows (once I make the changes needed to get it to compile).<br /><br />ScottScott Meyershttps://www.blogger.com/profile/05280964633768289328noreply@blogger.comtag:blogger.com,1999:blog-7101933101966798446.post-43868608344199509792012-04-05T17:12:52.514-07:002012-04-05T17:12:52.514-07:00It compile with gcc 4.8, though doesnt seem to run...It compile with gcc 4.8, though doesnt seem to run:<br /><br />g++-4.8 --version<br />g++-4.8 (GCC) 4.8.0 20120311 (experimental)<br />g++-4.8 --std=c++11 prog.cpp<br />./a.out prog.cpp <br />terminate called after throwing an instance of 'std::system_error'<br /> what(): Unknown error 18446744073709551615<br />Aborted<br /><br />I did not investigated much.<br /><br />With clang it fail compiling in GNU libstd++ headers (lots of errors seem related to atomics support).<br /><br />clang++ --version<br />clang version 3.1 (trunk 150359)<br />Target: x86_64-unknown-linux-gnu<br />Thread model: posix<br /><br /> fxAnonymoushttps://www.blogger.com/profile/17210197569883727100noreply@blogger.com