Josh Haberman <haber...@google.com> added the comment: This behavior is covered by the standard. The following C translation unit is valid according to C99:
struct PyTypeObject; extern struct PyTypeObject Foo_Type; struct PyTypeObject *ptr = &Foo_Type; Specifically, &Foo_Type is an "address constant" per the standard because it is a pointer to an object of static storage duration (6.6p9). The Python docs contradict this with the following incorrect statement: > However, the unary ‘&’ operator applied to a non-static variable like > PyBaseObject_Type() is not required to produce an address constant. This statement is incorrect: 1. PyBaseObject_Type is an object of static storage duration. (Note, this is true even though it does not use the "static" keyword -- the "static" storage-class specifier and "static storage duration" are separate concepts). 2. It follows that &PyBaseObject_Type is required to produce an address constant. because it is a pointer to an object of static storage duration. MSVC rejects this standard-conforming TU when __declspec(dllimport) is added: https://godbolt.org/z/GYrfTqaGn I am pretty sure this is out of compliance with C99. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue15870> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com