stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Sebor <se...@roguewave.com>
Subject Re: ifstream Behaves Strangely when using Static Linking
Date Tue, 06 Mar 2007 20:41:09 GMT
Patrick Happel wrote:
> Sorry, first time using this list.  Here's the text of the .cpp file,
> and the input file:

I've been able to reproduce this in an 11s (archive, debug,
ILP32) build of the library. It looks like the global mask
table used by the ctype<char> facet in the "C" locale to
determine whether a character is whitespace or not either
isn't being initialized correctly in the -bstatic case, or
its address is wrong.

On a hunch I tried creating a true archive library using ar
(and leaving out -qmkshrobj) as mentioned in STDCXX-286 (see
http://issues.apache.org/jira/browse/STDCXX-286), and the
problem cleared up.

If the customer is using -bstatic as a workaround to force
static linking I would suggest to them to try the approach
that worked for me until we've fixed it (hopefully in the
next release of the library).

Martin

> 
> Newtester.cpp:
> 
> #include <stdlib.h>
> #include <fstream>
> #include <iostream>    
> #include <string>
> 
> int main()
> {
> 	std::ifstream fMap("./newmap",std::ios::in);
> 
> 	if (!fMap)
> 	{
> 		std::cerr << "cannot open bubble map" << std::endl;
> 		return false;
> 	}
> 
> 	std::string str1, str2, str3;
> 
> 	while (fMap.peek() != EOF)
> 	{
> 		fMap >> str1 >> str2 >> str3;
> 		std::cerr << "first column value is: " << str1 <<
> std::endl;
> 	}
>   return 0;
> }
> 
> 
> Newmap:
> 
> taco burrito quesedilla
> foo bar boofar
> old now new
> one two three
> 
> 
> -----Original Message-----
> From: Patrick Happel [mailto:phappel@quovadx.com] 
> Sent: Tuesday, March 06, 2007 8:28 AM
> To: stdcxx-dev@incubator.apache.org
> Subject: ifstream Behaves Strangely when using Static Linking
> 
>   A customer I'm supporting has run into an issue with ifstream when
> linking an application statically on AIX.  I've attached a test case
> that reads tokens in from a file three at a time, and prints them out.
> When compiled with dynamic linking, the application behaves as expected,
> but when compiled with static linking, the entire file is put into one
> string, without breaking on whitespace.  I'm using a 12s build type for
> this, so I'm not sure why there should be a problem with using static
> linking.  The customer is specifying the linking via the '-bstatic'
> flag.  I'm not entirely sure if this option is supported by the Standard
> Library.  I noted in the documentation for Visual Age that the Native
> Standard Library is always compiled with dynamic linking.  I'm not sure
> of the reasons for this, but figured I should point it out.
>   I tested this on AIX 5L v5.3, using XLC 7.0 64-bit, with patches up to
> 8/31/2005 applied.  The Standard Library being used is version 4.1.4.
> I've attached the test file, and included included the output I get
> below.  Any input would be appreciated.
>  
> Thanks,
>  -Patrick Happel
>  
> Rogue Wave Software,
> A QUOVADX(tm) division
> Technical Support
> Phone: 303-545-3227 -- 1-800-404-4767
> E-mail: support@roguewave.com <mailto:support@roguewave.com>
> Web: http://www.roguewave.com/support <http://www.roguewave.com/support>
> 
> 
> 
> 
> [phappel@gemini filetest]$ xlCcore_r -q64
> -I/package/1/compilers/5.2.0/va70_20050831/root/usr/vacpp/include -I. -O
> -D_REENTRANT -qsuppress=1500-029 -qnotempinc -c newtester.cpp -o
> newtester.o [phappel@gemini filetest]$ xlCcore_r -q64 -O -D_REENTRANT
> -Wl,-bh:5
> -qnotempinc -o newtester newtester.o -lC    
> [phappel@gemini filetest]$ ./newtester
> first column value is: taco
> first column value is: foo
> first column value is: old
> first column value is: one
> first column value is: one
> [phappel@gemini filetest]$ xlCcore_r -q64 -O -D_REENTRANT -Wl,-bh:5
> -qnotempinc -o newtester newtester.o -bstatic -lC -bdynamic
> [phappel@gemini filetest]$ ./newtester first column value is: taco first
> column value is: foo first column value is: old first column value is:
> one first column value is: one [phappel@gemini filetest]$ cp
> newtester.cpp ~/temp/newtester2.cpp [phappel@gemini filetest]$ xlCcore_r
> -q64 -D_RWCONFIG=12s10g -I./../Ed9_12s10g/include
> -I./../Ed9_12s10g/include/ansi -I./../Ed9_12s10g/ -I. -O -D_REENTRANT
> -qsuppress=1500-029 -qnotempinc -c newtester.cpp -o newtester.o
> [phappel@gemini filetest]$ xlCcore_r
> -q64 -O -D_REENTRANT -Wl,-bh:5 -qnotempinc -D_RWCONFIG=12s10g -o
> newtester newtester.o -L./../Ed9_12s10g/lib -lstd12s10g [phappel@gemini
> filetest]$ ./newtester first column value is: taco first column value
> is: foo first column value is: old first column value is: one first
> column value is: one [phappel@gemini filetest]$ xlCcore_r -q64 -O
> -D_REENTRANT -Wl,-bh:5 -qnotempinc -D_RWCONFIG=12s10g -o newtester
> newtester.o -bstatic -L./../Ed9_12s10g/lib -lstd12s10g -bdynamic
> [phappel@gemini filetest]$ ./newtester first column value is: taco
> burrito quesedilla foo bar boofar old now new one two three
> 
> [phappel@gemini filetest]$ 
>  


Mime
View raw message