Re: Update on the Modern C initiative

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Florian Weimer wrote:
> Although the critical type size mismatch happens on 32-bit architectures
> and Windows only.  Problems like these are the reason why I don't think
> the Clang approach of restricting to incompatible-function-pointer-types
> only makes much sense.

Uhm, yeah, there are certainly cases where the complaint about mismatched 
pointer types is valid. But last I checked, the warning that is now being 
turned into an error also complained about "mismatches" where the types are 
actually exactly the same on the given architecture, such as int vs. long on 
32-bit (or 64-bit Windows), or long vs. long long on 64-bit LP64. And those 
"mismatches" can easily happen without being an actual issue, because, e.g., 
the program uses its own definition equivalent to something like size_t or 
ptrint_t (especially the latter, since it is non-C90 and hence considered 
non-standard by the large pool of software still targeting C90 only, but I 
have also seen a lot of custom size_t/ssize_t reinventions) and passes a 
pointer to that where a size_t * or ptrint_t * or such is expected. 

E.g., I have seen Java bindings doing something like:
jlong foo;
#if SIZEOF_SIZE_T == 8
  function_that_expects_an_ssize_t_pointer(&foo);
#else
  ssize_t temp = (ssize_t) foo;
  function_that_expects_an_ssize_t_pointer(&temp);
  foo = (jlong) temp;
#endif

Of course, the compiler has no way to know whether the code is doing 
something like this or just incorrectly assuming that 
sizeof(ssize_t)==sizeof(jlong) (i.e., 8) everywhere.

        Kevin Kofler
--
_______________________________________________
devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Users]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]

  Powered by Linux