On Oct 29, 2012, at 6:08 AM, thwang <[email protected]> wrote:
> Hi all
>
> I have recently change compiler, from gcc(libstdc++) to clang(libc++) on
> iOS. After the change the generation of key, using the following snib, never
> terminates.
> ...
> CryptoPP::RSAES< CryptoPP::OAEP <CryptoPP::SHA1> >::PrivateKey
> privateSessionKey;
> CryptoPP::AutoSeededX917RNG<CryptoPP::AES> rng;
> privateSessionKey.GenerateRandomWithKeySize(rng, 2048);
> ...
>
> I haunted it dow to be related to the use of vector<bool> in
> nbtheory.cpp(line 310) which seems to give unexpected values when using the
> clang(and libc++).
> ..
> 308 bool PrimeSieve::NextCandidate(Integer &c)
> 309 {
> 310 bool safe = SafeConvert(std::find(m_sieve.begin()+m_next,
> m_sieve.end(), false) - m_sieve.begin(), m_next);
> 311 assert(safe);
> 312 if (m_next == m_sieve.size())
> ..
>
> I isolated the issue to the following example:
> std::vector<bool> my_vector;
> my_vector.push_back(true);
> my_vector.push_back(false);
> my_vector.push_back(true);
> my_vector.push_back(true);
> my_vector.push_back(true);
> my_vector.push_back(false);
> my_vector.push_back(true);
> long idx = std::find(my_vector.begin()+2, my_vector.end(), false) -
> my_vector.begin();
> std::cout << "idx:" << idx << std::endl;
>
> which returns
> idx:0
> when using clang (and libc++) and
> idx:5
> when using gcc (and libstdc++) as expected.
>
> Can anybody confirm this issue?
Nice catch! - thanks for the simple test case.
I can confirm that this issue is present in the shipping libc++ (tested with
Xcode 4.5.1)
I can also confirm that this issue has been fixed in the libc++ source
repository at:
https://llvm.org/svn/llvm-project/libcxx/trunk
A short term fix would be to replace just the file "__bit_reference" in your
Xcode installation (after backing up, of course) with the one from the libc++
source repo.
On my system, that's in:
/Applications/Xcode.app/Contents/Developer/Toolchain/XcodeDefault.xctoolchain/usr/lib/c++/v1/__bit_reference
-- Marshall
Marshall Clow Idio Software <mailto:[email protected]>
A.D. 1517: Martin Luther nails his 95 Theses to the church door and is promptly
moderated down to (-1, Flamebait).
-- Yu Suzuki
--
You received this message because you are subscribed to the "Crypto++ Users"
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at
http://www.cryptopp.com.