git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] fix clang -Wtautological-compare with unsigned enum

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Jan 18, 2013, 18:52 UTC
Message-ID
<CA+55aFzTy0x6X_dK54RO13s+zG9ynWG_8Ei=ZwT8a5B4=LQ94A@mail.gmail.com>
In-Reply-To
<CABURp0pj35j7+W_0gYNud2uuEoahugOMBW9ezTgPZ7YvgnBz8w@mail.gmail.com>
On Fri, Jan 18, 2013 at 9:15 AM, Phil Hord <phil.hord@gmail.com> wrote:
Show 5 quoted lines
>
> Yes, I can tell by the wording of the error message that you are right
> and clang has a problem.  But the git code it complained about does
> have a real problem, because the result of "signed int a = ULONG_MAX"
> is implementation-defined.
Only theoretically.

Git won't work on machines that don't have 8-bit bytes anyway, so worrying about the theoretical crazy architectures that aren't two's complement etc isn't something I'd care about.

There's a whole class of "technically implementation-defined" issues in C that simply aren't worth caring for. Yes, the standard is written so that it works on machines that aren't byte-addressable, or EBCDIC or have things like 18-bit words and 36-bit longwords. Or 16-bit "int" for microcontrollers etc.

That doesn't make those "implementation-defined" issues worth worrying about these days. A compiler writer could in theory make up some idiotic rules that are still "valid by the C standard" even on modern machines, but such a compiler should simply not be used, and the compiler writer in question should be called out for being an ass-hat.

Paper standards are only worth so much. And that "so much" really isn't very much.

                Linus
Previous: Phil HordNext: John Keeping
Message 27 of 35 in “fix some clang warnings”
  1. fix some clang warningsMax Horn, Jan 16, 2013
  2. Jeff KingJan 16, 2013
  3. Junio C HamanoJan 16, 2013
  4. Antoine PelisseJan 16, 2013
  5. John KeepingJan 16, 2013
  6. Max HornJan 16, 2013
  7. Jeff KingJan 16, 2013
  8. Jeff KingJan 16, 2013
  9. Jeff KingJan 16, 2013
  10. John KeepingJan 16, 2013
  11. Jeff KingJan 16, 2013
  12. Antoine PelisseJan 16, 2013
  13. John KeepingJan 16, 2013
  14. Jeff KingJan 16, 2013
  15. John KeepingJan 16, 2013
  16. John KeepingJan 17, 2013
  17. 1/2 fix clang -Wconstant-conversion with bit fieldsAntoine Pelisse, Jan 16, 2013
  18. 2/2 fix clang -Wtautological-compare with unsigned enumAntoine Pelisse, Jan 16, 2013
  19. Antoine PelisseJan 16, 2013
  20. Antoine PelisseJan 17, 2013
  21. John KeepingJan 17, 2013
  22. combine-diff: suppress a clang warningJohn Keeping, Jan 17, 2013
  23. Linus TorvaldsJan 17, 2013
  24. Antoine PelisseJan 17, 2013
  25. John KeepingJan 17, 2013
  26. Phil HordJan 18, 2013
  27. Linus TorvaldsJan 18, 2013
  28. John KeepingJan 16, 2013
  29. Antoine PelisseJan 16, 2013
  30. Antoine PelisseJan 16, 2013
  31. Junio C HamanoJan 16, 2013
  32. Junio C HamanoJan 16, 2013
  33. Tomas CarneckyJan 16, 2013
  34. Matthieu MoyJan 16, 2013
  35. Miles BaderFeb 1, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.