Re: Discussion about why GNU/Linux system upgrades cause old programs to break
Arsen Arsenović <[email protected]>
| Newsgroups | gmane.emacs.devel |
|---|---|
| Message-ID | <[email protected]> |
Richard Stallman <[email protected]> writes: > [[[ To any NSA and FBI agents reading my email: please consider ]]] > [[[ whether defending the US Constitution against all enemies, ]]] > [[[ foreign or domestic, requires you to follow Snowden's example. ]]] > > > > So I wonder, why was the result failure rather than such warnings. > > > Eli, would you like to investigate why? > > > > > > ~$ gcc -x c -std=gnu89 - <<<'main(argc, argv) int argc; char **argv; { > > > char *x = reallocarray(strdup (argv[0]), 100, 1); printf ("%d %s\n", argc, x); > > > exit (0); }' > > > > > > What is the problem with this one? Is it that the value of strdup is 64 bits > > > and reallocarray's first argument is taken as int? > > > Yes, the implicit declaration that K&R C specifies for undeclared > > functions can easily mismatch what the actual definition is, and indeed > > it is incorrect for reallocarray, so it breaks. > > Similar code (in Emacs 23 ?) worked in the past -- this problem did not > occur, it seems. Why did that code work then? Maybe it ran on a 32-bit machine, where pointers and ints are both 32-bit values. Maybe the user got lucky, and 'malloc' never returned a pointer greater than or equal to 2<<32, so that truncating it had no effect. Or, maybe Emacs included <string.h> and thus had the correct prototypes for the above functions available. -- Arsen Arsenović
signature.asc
(application/pgp-signature, 418 B)
-----BEGIN PGP SIGNATURE----- iQECBAEWCgCqFiEE/uKz0RP8AKMWLWBhUsKUMB6ixJMFAmqAsesbFIAAAAAABAAO bWFudTIsMi41KzEuMTIsMiwyXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25z Lm9wZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXRGRUUyQjNEMTEzRkMwMEEzMTYyRDYw NjE1MkMyOTQzMDFFQTJDNDkzEBxhcnNlbkBhYXJzZW4ubWUACgkQUsKUMB6ixJOq hwEA8gswZO2mNSK6lJhGQ34VgAps1Wngn1yLJe5Ij5gDXV4BAPyYWNJj9NDBh/8h JjX63zlVMMjcxCL5dCd6kH432zgL =zN5u -----END PGP SIGNATURE-----