From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Lafferty, Paul" To: "'gcc-bugs@gcc.gnu.org'" Subject: Bug Report Date: Tue, 29 Feb 2000 13:36:00 -0000 Message-id: <47FCB6DBADBFD211A36700104B95BD8320315A@spacemsg2.jhuapl.edu> X-SW-Source: 2000-02/msg00921.html Content-type: multipart/mixed; boundary="----------=_1583533096-4114-154" List-Id: This is a multi-part message in MIME format... ------------=_1583533096-4114-154 Content-length: 493 <> GCC version: 2.95.2 System: Sun (Sparc Solaris) Error compiling STL containers pair, string, and list combined into a list of string pairs. See enclosed main routine: TestStringContainersMain.cpp compile command used: g++ TestStringContainersMain.cpp Compiler error message is: error: can't compute value of an expression involving an external symbol. Note: Compiles OK under GCC version 2.91.66. Sincerely, Paul Lafferty paul.lafferty@jhuapl.edu ------------=_1583533096-4114-154 Content-Type: text/x-c++; charset=us-ascii; name="TestStringContainersMain.cpp" Content-Disposition: inline; filename="TestStringContainersMain.cpp" Content-Transfer-Encoding: base64 Content-Length: 1139 I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVk ZSA8bGlzdD4KI2luY2x1ZGUgPHV0aWxpdHk+Cgp1c2luZyBuYW1lc3BhY2Ug c3RkOwoKaW50IG1haW4oKQp7CiAgICBwYWlyPHN0cmluZywgc3RyaW5nPiBz dHJpbmdfcGFpcigiRkFRIiwgIkZyZXF1ZW50bHkgQXNrZWQgUXVlc3Rpb25z Iik7CgogICAgbGlzdDwgcGFpcjxzdHJpbmcsIHN0cmluZz4gPiBzdHJpbmdf cGFpcl9saXN0MTsKCiAgICBsaXN0PCBwYWlyPHN0cmluZywgc3RyaW5nPiA+ OjppdGVyYXRvciBsaXN0X2l0ZXJhdG9yOwoKICAgIC8vIFdoeSB3b24ndCB0 aGUgbmV4dCB0d28gbGluZXMgY29tcGlsZSB1bmRlciBnKysvZ2NjIDIuOTUu Mj8KICAgIC8vIFRoZXkgZG8gdW5kZXIgZysrL2djYyB2ZXJzaW9uIDIuOTEu NjYuCgogICAgc3RyaW5nX3BhaXJfbGlzdDEucHVzaF9iYWNrKHN0cmluZ19w YWlyKTsKCiAgICBsaXN0PCBwYWlyPHN0cmluZywgc3RyaW5nPiA+IHN0cmlu Z19wYWlyX2xpc3QyID0gc3RyaW5nX3BhaXJfbGlzdDE7CgogICAgbGlzdF9p dGVyYXRvciA9IHN0cmluZ19wYWlyX2xpc3QxLmJlZ2luKCk7CgogICAgY291 dCA8PCAibGlzdCAxOiAiIDw8IGxpc3RfaXRlcmF0b3ItPmZpcnN0IDw8ICIg IgogICAgICAgICA8PCBsaXN0X2l0ZXJhdG9yLT5zZWNvbmQgPDwgZW5kbDsK CiAgICBsaXN0X2l0ZXJhdG9yID0gc3RyaW5nX3BhaXJfbGlzdDIuYmVnaW4o KTsKCiAgICBjb3V0IDw8ICJsaXN0IDI6ICIgPDwgbGlzdF9pdGVyYXRvci0+ Zmlyc3QgPDwgIiAiCiAgICAgICAgIDw8IGxpc3RfaXRlcmF0b3ItPnNlY29u ZCA8PCBlbmRsOwoKICAgIHJldHVybiAwOwp9Cg== ------------=_1583533096-4114-154-- >>From martin@loewis.home.cs.tu-berlin.de Tue Feb 29 13:42:00 2000 From: "Martin v. Loewis" To: wieland.kroetz@arcormail.de Cc: gcc-bugs@gcc.gnu.org Subject: Re: bug Date: Tue, 29 Feb 2000 13:42:00 -0000 Message-id: <200002292140.WAA26036@loewis.home.cs.tu-berlin.de> References: <38BC1517.28AF590E@arcormail.de> X-SW-Source: 2000-02/msg00922.html Content-length: 337 > and produces the wrong output: Thanks for your bug report. This is not a bug in gcc, but in your code. The data() function does not return a zero-terminated string; you need to use the c_str() function for that. If you replace all data() calls with c_str() your code works fine. Please read a C++ book for details. Regards, Martin