Is it same deprecated in GNU as in Microsoft C runtime?
Is deprecation, if there is such in GNU C, enforced by later standard of C after 89/90 or the compiler?
If it's GNU C compiler, since when and does it provide such a secure alternative memory operating function like
memcpy_s
to the deprecatedmemcpy
in Microsoft C?If it's later C standard after 89/90, since when and does it provide such a secure alternative memory operating function like
memcpy_s
to the deprecatedmemcpy
in Microsoft C?If no such deprecation in GNU C runtime, is there a function which is neither among those memory operations (name started with
mem
) nor the one I know asbcopy
, but I can use to copy memory safe in that it takes a parameter about length of the destination?If there is/are, could you please list as many as possible?
Asked
Active
Viewed 3,607 times
3

Deduplicator
- 44,692
- 7
- 66
- 118

Yang
- 777
- 1
- 10
- 19
-
1Let me assure you that the deprecation of good old `memcpy` is a mere Microsoft invention, trying to impose a kind of so-called "safety" that doesn't really fit the domain. There is no problem in using `memcpy` and if Microsoft some day dares to completely drop it (which won't ever happen), they'll loose any customers they might still have. – Christian Rau Aug 18 '12 at 10:22
-
Also check http://stackoverflow.com/questions/870019/memcpy-in-secure-programming – Qnan Aug 18 '12 at 10:32
-
@Qnan I have viewed that before posting these questions. That's why I wrote `...nor the one I know as bcopy,...` in question 5. – Yang Aug 18 '12 at 10:39
-
@ChristianRau I think I'm liberal in the first 4 questions. I would appreciate the answer more to question 5 and 6. – Yang Aug 18 '12 at 10:41
-
@Yang that was basically the answer to the parts 5 and 6 of your question -- you don't need `memcpy_s` or its variations to write safe code. – Qnan Aug 18 '12 at 10:41
-
If you want bound checking, why not implement a wrapper over the array yourself and use that? – Qnan Aug 18 '12 at 10:42
-
@Qnan I was about to do until the last moment before posting questions. I was in the hope that such snippet exists in either glibc or what I might have missed. – Yang Aug 18 '12 at 10:51
2 Answers
6
The function memcpy
is not deprecated. It's one of the safest and most useful functions in the library. The memcpy_s
function became standard in C11 (optional, see "Bounds-checking interface" in Annex K).

cnicutar
- 178,505
- 25
- 365
- 392
6
memcpy_s
has been in added since C11 but is an optional extension. memcpy
has not been deprecated in C and is not an obsolescent function.
glibc
as of now does not support _s
functions and there is no plan (AFAIK) for glibc
team to support them.

ouah
- 142,963
- 15
- 272
- 331
-
-
5`memcpy` *has always* taken an argument specifying the length of the destination. MS is simply on crack with regards to this one. – R.. GitHub STOP HELPING ICE Aug 18 '12 at 12:14