Deutsch English Français Italiano |
<87zfrn45n3.fsf@nosuchdomain.example.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!3.eu.feeder.erje.net!feeder.erje.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson <Keith.S.Thompson+u@gmail.com> Newsgroups: comp.lang.c Subject: Re: "undefined behavior"? Date: Fri, 14 Jun 2024 13:43:28 -0700 Organization: None to speak of Lines: 34 Message-ID: <87zfrn45n3.fsf@nosuchdomain.example.com> References: <666a095a$0$952$882e4bbb@reader.netnews.com> <8t3k6j5ikf5mvimvksv2t91gbt11ljdfgb@4ax.com> <666a18de$0$958$882e4bbb@reader.netnews.com> <87y1796bfn.fsf@nosuchdomain.example.com> <666a2a30$0$952$882e4bbb@reader.netnews.com> <87tthx65qu.fsf@nosuchdomain.example.com> <v4dtlt$23m6i$1@dont-email.me> <NoEaO.2646$J8n7.2264@fx12.iad> <v4fc5j$2cksu$1@dont-email.me> <87le385u1s.fsf@nosuchdomain.example.com> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Fri, 14 Jun 2024 22:43:29 +0200 (CEST) Injection-Info: dont-email.me; posting-host="10f324c947246626491173dedfdc5917"; logging-data="3202594"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18cY8s4wJEfK2ZEFpcRlXfV" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Cancel-Lock: sha1:EvWWwF5JtTA50ID5LBEvA5zt7Lk= sha1:RxtLvY3im2LAWSKSc9J0hA8QpWw= Bytes: 2712 Keith Thompson <Keith.S.Thompson+u@gmail.com> writes: [...] > I don't know. The default gcc on my system diagnoses it by default, but > various versions of gcc I've built from source do not. Perhaps Ubuntu > configures gcc differently. (Ubuntu 22.04.4, gcc 11.4.0.) I'm building > gcc 11.4.0 from source, and I'll compare its behavior to that of > Ubuntu's gcc 11.4.0-1ubuntu1~22.04. [...] Context: Warning about incorrect printf format strings, such as `printf("%d\n", strlen(s));` ("%d" requires an int argument but strlen() returns a result of type size_t). I've confirmed that, on my Ubuntu 22.04 system, the system-provided gcc ("Ubuntu 11.4.0-1ubuntu1~22.04") warns about the mismatch, but gcc 11.4.0 built from source does not. So Ubuntu (or its upstream Debian) does a custom build of gcc that enables "-Wformat" by default. Confirmed by this answer on Stack Overflow: <https://stackoverflow.com/a/50112401/827263> """ This is not caused by a difference in GCC versions. Rather, Ubuntu has modified GCC to enable -Wformat -Wformat-security by default. If you pass those options on Arch Linux, you should see the same behaviour there. """ (The answer contains a link to a web page that no longer exists.) -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */