public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/17639] New: ++ increment not working in std::string.insert
@ 2004-09-23 20:37 barnarr at cc dot wwu dot edu
  2004-09-23 20:54 ` [Bug c++/17639] " pinskia at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: barnarr at cc dot wwu dot edu @ 2004-09-23 20:37 UTC (permalink / raw)
  To: gcc-bugs

I posted below the code to duplicate this bug.  I am performing a "i++" inside a
std::string.insert(...) function call and it appears that the "i" value is not
incrementing.  This has been tested on multiple versions of GCC (2.8.1, 3.3.3,
3.3.4) running on Linux, BSD, and Windows (via Cygwin).  The code does work
properly in Visual Studio .NET.  I tried different -O optimizations, including
turning them off, and the problem persisted.

Compiled this code by typing:
g++ -Wall -o main ./main.cpp

Haven't reported a bug before, so I don't know what the "host triplet, target
triplet, and build triplet" things are.

Let me know if you need any more information.  Hope this helps.
----------------------------------------------------------------------------
$ gcc -v
Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/specs
Configured with: /var/tmp/portage/gcc-3.3.3-r6/work/gcc-3.3.3/configure
--prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/3.3
--includedir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include
--datadir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3
--mandir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3/man
--infodir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3/info --enable-shared
--host=i686-pc-linux-gnu --target=i686-pc-linux-gnu --with-system-zlib
--enable-languages=c,c++ --enable-threads=posix --enable-long-long
--disable-checking --disable-libunwind-exceptions --enable-cstdio=stdio
--enable-version-specific-runtime-libs
--with-gxx-include-dir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/g++-v3
--with-local-prefix=/usr/local --enable-shared --enable-nls
--without-included-gettext --disable-multilib --enable-__cxa_atexit
--enable-clocale=generic
Thread model: posix
gcc version 3.3.3 20040412 (Gentoo Linux 3.3.3-r6, ssp-3.3.2-2, pie-8.7.6)
----------------------------------------------------------------------------
SOURCE CODE ----------------------------------------------------------------
----------------------------------------------------------------------------
#include <iostream>
#include <string>
 
using namespace std;
 
int main(void) {
  string array1;
  string array2;
  int i;
 
  array1 = "Test String #1";
  array2 = "";
 
  cout << "[" << array1 << "][" << array2 << "]" << endl;
   
  i = 0;
  while(i < (int)strlen(array1.c_str())) {
    // array2.insert(i, &array1[i], 1); ++i;    // <-- This line works
    array2.insert(i, &array1[i++], 1);          // <-- This line doesn't work
  }
 
  cout << "[" << array1 << "][" << array2 << "]" << endl;
   
  return 0;
}

-- 
           Summary: ++ increment not working in std::string.insert
           Product: gcc
           Version: 3.3.4
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: barnarr at cc dot wwu dot edu
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17639


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c++/17639] ++ increment not working in std::string.insert
  2004-09-23 20:37 [Bug c++/17639] New: ++ increment not working in std::string.insert barnarr at cc dot wwu dot edu
@ 2004-09-23 20:54 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-09-23 20:54 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-09-23 20:54 -------
The code you posted is undefined, you are modifing i and also getting the value of i without a sequence 
point inbetween them.

*** This bug has been marked as a duplicate of 11751 ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE
            Summary|++ increment not working in |++ increment not working in
                   |std::string.insert          |std::string.insert


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17639


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-09-23 20:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-23 20:37 [Bug c++/17639] New: ++ increment not working in std::string.insert barnarr at cc dot wwu dot edu
2004-09-23 20:54 ` [Bug c++/17639] " pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).