Boost logo

Boost Users :

From: Samuel Krempp (krempp_at_[hidden])
Date: 2004-12-08 13:57:26


Filipe Sousa wrote:

> Hi!
>
> I get a segmentation fault with Intel compiler 8.1 using the fallowing
> code
>
> #include <boost/format.hpp>
> #include <iostream>
>
> int main() {
> std::cout << boost::format("writing %1%, x=%2% : %3%-th try") % "toto"
> %
> 40.23 % 50 << std::endl;
> return 0;
> }
>
> (idb) bt
> #0 0x0804aba8 in ctype<char>::is (this=0x41016b50, __m=2048, __c=49 '1')
> #at
> ctype_inline.h:40
> #1 0x08051d55 in std::isdigit (__c=49 '1', __loc=& { ... }) at

> The same code works perfectly with gcc-3.4.2 under linux. Is this a bug in
> boost format library or a Intel compiler problem?

The segfault takes place inside the compiler's standard library functions,
so it seems like the bug is in icc. Segfaulting inside isdigit is not a
conformant behaviour :)

Though, that might be the result of a binary link problem, or a strange
thing going on.
Did you try calling std::isdigit directly, on facets constructed the way
format constructs them ?

the facet object is coming from those lines :

#if !defined(BOOST_NO_STD_LOCALE)
        const std::ctype<Ch> & fac = BOOST_USE_FACET( std::ctype<Ch>,
getloc());
#else
        io::basic_oaltstringstream<Ch, Tr, Alloc> fac;
        //has widen and narrow even on compilers without locale
#endif

(so 'fac' is in fact a stream, in case the compiler doesnt support locales.
this way the workarounds needed minimal extra code.. But anyway I think
icc has locales, and fac is constructed with BOOST_USE_FACET )

It might also be caused by the rest of the code fiddling some memory areas.
(is this line of code causing the same bug when nothing else is executed ?)
 

-- 
Samuel

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net