Will rand() ever be deprecated?

I know std::random_shuffle is being deprecated and removed, but I want to know if std::rand() is ever going to be deprecated. I think not because rand() comes from C so unless C deprecates rand() I don't think C++ will do it, because C++ doesn't deprecate C library features just like that, right? In C++11 they even added a lot of C99 stuff at the same time as C++ features was added to do mostly the same thing (e.g. atoll and stoll).

This paper seem to think that rand() should be deprecated.
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3775.pdf
I can't find a recent draft of the latest standards so I can't check it myself but the standard settled with just discouraging it's use?

http://en.cppreference.com/w/cpp/numeric/random/rand
rand() is not recommended for serious random-number generation needs, like cryptography. It is recommended to use C++11's random number generation facilities to replace rand(). (since C++11)
Last edited on
Here's what current (april 10th 2015, document n4431) C++17 draft actually says:

26.8[c.math]/5
[ Note: The random number generation (26.5) facilities in this standard are often preferable to rand, because rand’s underlying algorithm is unspecified. Use of rand therefore continues to be nonportable, with unpredictable and oft-questionable quality and performance. — end note ]

By the way, rand's reentrant replacement rand_r() is obsolete in POSIX http://pubs.opengroup.org/onlinepubs/9699919799/functions/rand.html -- I guess they couldn't kill rand itself exactly because it's part of C
Last edited on
Thank you for letting me know. :)
Topic archived. No new replies allowed.