2011/11/5 K. Frank <[email protected]>: > Hello Everyone! > > I see the same behavior on a couple of other mingw-w64 versions. > > (See below.) > > On Sat, Nov 5, 2011 at 1:22 PM, K. Frank <[email protected]> wrote: >> Hello Kai and Ruben! >> >> On Sat, Nov 5, 2011 at 11:43 AM, Kai Tietz <[email protected]> wrote: >>> Errm, well, this seems not to be my day. Sure it is promoted to wider >>> scalar. >>> ... >>> Kai >> >> With all due respect, I think the issues of how std::string::npos is defined >> and how signed / unsigned or narrower / wider conversions are supposed >> to work are red herrings. >> >> Depending on those details, the test code should either go into an infinite >> loop, or loop a couple of times. >> >> But in any event, if the "top of loop" (line 36): >> >> printf ("xsputn: top of loop, pos = %d\n", pos); >> >> is executed, then the "bottom of loop" (line 44): >> >> printf ("xsputn: bottom of loop, pos = %d\n", pos); >> >> should also be executed. But it's not. Here's the output of the program: >> >> C:\>stdout_stream_error >> hello... >> xsputn: top of loop, pos = 0 >> Message 1 (with '\n')... >> xsputn: bottom of loop, pos = 24 >> xsputn: top of loop, pos = 24 >> goodbye! >> >> The second time through the loop, the loop doesn't complete, and line >> 44 does not get executed. >> >> Something seems wrong with the generated code, regardless of whether >> or not we properly understand std::string::npos and the details of integral >> conversions. >> >> (I should emphasize that this is not an "issue" for me. I have my code >> working properly. I'm just trying to point out what seems to be a bug >> in the compiler if anybody "upstream" cares.) >> >> Thanks for taking a look at this. >> >> K. Frank > > Okay, I tried this on two more compiler versions, and I get the same > result, namely that the loop seems to "exit" early. > > These are two Ozkan Sezer builds: 4.4.5 and 4.5.2: > > g++ (GCC) 4.4.5 20101001 (release) [svn/rev.164871 - mingw-w64/oz] > g++ (GCC) 4.5.2 20101002 (prerelease) [svn/rev.164902 - mingw-w64/oz] > > I compile as follows: > > g++ -g -o stdout_stream_error stdout_stream_error.cpp > > and the program gives the same output as before, namely: > > C:\>stdout_stream_error > hello... > xsputn: top of loop, pos = 0 > Message 1 (with '\n')... > xsputn: bottom of loop, pos = 24 > xsputn: top of loop, pos = 24 > goodbye! > > Now I will say that seeing the same behavior in several versions of the > compiler does make it a little less likely that it's a compiler bug, on the > theory that such a bug would already have been noticed and fixed. > > Nonetheless, I am sticking with my analysis, and I think there is a bug > in the compiler. > > Best. > > > K. Frank
The only thing it might could be here, is that erase-call raises an exception, but why you see the goodbye message here than? Kai ------------------------------------------------------------------------------ RSA(R) Conference 2012 Save $700 by Nov 18 Register now http://p.sf.net/sfu/rsa-sfdev2dev1 _______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
