Re: How can Autoconf help with the transition to stricter compilation defaults?

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

 



On Wed, Nov 16, 2022 at 4:02 PM Michael Matz via Gcc <gcc@xxxxxxxxxxx> wrote:
>
> Hey,
>
> On Wed, 16 Nov 2022, Alexander Monakov wrote:
>
> > > The idea is so obvious that I'm probably missing something, why autoconf
> > > can't use that idiom instead.  But perhaps the (historic?) reasons why it
> > > couldn't be used are gone now?
> >
> > Ironically, modern GCC and LLVM optimize '&foobar != 0' to '1' even at -O0,
> > and thus no symbol reference remains in the resulting assembly.
>
> Err, right, *head-->table*.
> Playing with volatile should help:
>
> char foobar(void);
> char (* volatile ptr)(void);
> int main(void) {
>     ptr = foobar;
>     return ptr != 0;
> }

using printf for foobar this works even with GCC 2.95.2 and with trunk
and -Wall diagnoses

t.c:1:6: warning: conflicting types for built-in function 'printf';
expected 'int(const char *, ...)' [-Wbuiltin-declaration-mismatch]
    1 | char printf(void);
      |      ^~~~~~
t.c:1:1: note: 'printf' is declared in header '<stdio.h>'
  +++ |+#include <stdio.h>
    1 | char printf(void);

so without -Werror this should be fine.

Richard.

>
>
> Ciao,
> Michael.




[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux