[issue45476] [C API] Disallow using PyFloat_AS_DOUBLE() as l-value

Oleg Iarygin report at bugs.python.org
Mon Nov 15 02:54:56 EST 2021


Oleg Iarygin <oleg at arhadthedev.net> added the comment:

Marc-Andre:
> Inlining is something that is completely under the control of the
used compilers. Compilers are free to not inline function marked for
inlining [...]

I checked the following C snippet on gcc.godbolt.org using GCC 4.1.2 and Clang 3.0.0 with <no flags>/-O0/-O1/-Os, and both compilers inline a function marked as static inline:

    static inline int foo(int a)
    {
        return a * 2;
    }

    int bar(int a)
    {
        return foo(a) < 0;
    }

So even with -O0, GCC from 2007 and Clang from 2011 perform inlining. Though, old versions of CLang leave a dangling original copy of foo for some reason. I hope a linker removes it later.

As for other compilers, I believe that if somebody specifies -O0, that person has a sound reason to do so (like per-line debugging, building precise flame graphs, or other specific scenario where execution performance does not matter), so inlining interferes here anyway.

----------
nosy: +arhadthedev

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45476>
_______________________________________


More information about the Python-bugs-list mailing list