Thread: I encourage everyone to have a glance over the Quake II source code

  1. #16
    Make Fortran great again
    Join Date
    Sep 2009
    Posts
    1,413
    Quote Originally Posted by brewbuck View Post
    Your pet frustration notwithstanding, clang is pretty much taking over everything now. Android and iOS are both compiled with it, and Microsoft is switching to it. Get over it, man.
    Why god why. I'll get over it when they fix it.

  2. #17
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    Quote Originally Posted by Epy View Post
    Why god why. I'll get over it when they fix it.
    Or at least offer a command-line switch to disable that behavior, or to enable the issuance of a warning in that scenario. I read What Every C Programmer Should Know About Undefined Behavior, and I understand their rationale for emitting those instructions, but I definitely agree with your complaints that they don't even emit a warning for recognized undefined behavior, when they generate those instructions.
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  3. #18
    Registered User
    Join Date
    Mar 2016
    Posts
    110
    Quote Originally Posted by Elkvis View Post
    Or at least offer a command-line switch to disable that behavior, or to enable the issuance of a warning in that scenario. I read What Every C Programmer Should Know About Undefined Behavior, and I understand their rationale for emitting those instructions, but I definitely agree with your complaints that they don't even emit a warning for recognized undefined behavior, when they generate those instructions.
    That article was useful.

    I finally know why languages deliberately allow for undefined behaviour!! My question was always why dont languages force the programmer to follow safe procedures. Turns out that by allowing for undefined behaviour but not stepping on it allows for performance gains.

  4. #19
    Registered User
    Join Date
    Mar 2016
    Posts
    110
    Quote Originally Posted by stevesmithx View Post
    My props to John Carmack and his team. And I like the fanboy in you, but this raises a question: If John is God, then what do you call Dennis Ritchie? Meta-God??
    Yep, Dennis Ritchie and Kernighan Meta Gods

  5. #20
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    Quote Originally Posted by Vespasian_2 View Post
    Yep, Dennis Ritchie and Kernighan Meta Gods
    And Ken Thompson and Bjarne Stroustrup.
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  6. #21
    Make Fortran great again
    Join Date
    Sep 2009
    Posts
    1,413
    Quote Originally Posted by Elkvis View Post
    Or at least offer a command-line switch to disable that behavior, or to enable the issuance of a warning in that scenario. I read What Every C Programmer Should Know About Undefined Behavior, and I understand their rationale for emitting those instructions, but I definitely agree with your complaints that they don't even emit a warning for recognized undefined behavior, when they generate those instructions.
    My gripe basically started with working on a project I'm involved with, OCE. I have spent months reducing compiler warnings and fixing small bugs, etc. GCC and MSVC were very happy with it, we even reduced some test failures in the process. Along comes Clang 3.4, suddenly test cases are failing out the wazoo. So, this is code that: a) compiles correctly with MSVC and GCC, b) does not issue any major warnings under -Wall -Wextra (and the MSVC equivalent), c) does not issue anything major under Clang's -Weverything, d) compiles without errors obviously.

    So, Clang's retard ass philosophy is to produce binaries that, even though no relevant warnings/errors are issued, doesn't work. What the ........ is the point of making the binary if it's not going to run?

    On top of this, this is actually two separate issues: one is a bug, because sometimes the ud2 only happens when optimization is used, other times it just happens period (intentional).

    It's really a shame because Clang is mostly faster than GCC and far better at producing meaningful warnings (or so I thought).

  7. #22
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,398
    Quote Originally Posted by Epy View Post
    Along comes Clang 3.4, suddenly test cases are failing out the wazoo.
    Your test cases failed! Yay! The system works! What's your problem again?

    So, Clang's retard ass philosophy is to produce binaries that, even though no relevant warnings/errors are issued, doesn't work.
    Let's get this part correct. Your code with undefined behavior doesn't work.

    It's really a shame because Clang is mostly faster than GCC and far better at producing meaningful warnings (or so I thought).
    I think the shame is that you've become mentally hung up on a particular issue and you've gone into an infinite loop. Move on!
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  8. #23
    Make Fortran great again
    Join Date
    Sep 2009
    Posts
    1,413
    Quote Originally Posted by brewbuck View Post
    Your test cases failed! Yay! The system works! What's your problem again?



    Let's get this part correct. Your code with undefined behavior doesn't work.



    I think the shame is that you've become mentally hung up on a particular issue and you've gone into an infinite loop. Move on!
    I'm disappointed in you, up until this point you've been a voice of reason and great knowledge, never thought I'd see you devolve into compiler fanboy status.

    Not going to hijack further; my last remark is that OCE compiles/works without hiccups on GCC, MSVC, ICC, Borland, and HP aC++ on many architectures (x86, SPARC, MIPS, ARM, etc etc). To say that Clang 3.2/3.4 comes along and is "right" in the 2010s vs. more mature compilers on a codebase professionally developed (OPEN CASCADE) dating back to the 90s, is retarded. On top of direct professional efforts by the company that makes this CAD kernel, others have basically done all we can to ensure code quality, evaluating as many compiler warnings from different compilers and using static analyzers, etc.

  9. #24
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by brewbuck View Post
    Let's get this part correct. Your code with undefined behavior doesn't work.
    This.

    You're being sour because clang actually traps your bugs, which no other compiler is able to. Deal with it. Fix it. Move on. I'd say it's retarded to rely on undefined behaviour.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  10. #25
    Make Fortran great again
    Join Date
    Sep 2009
    Posts
    1,413
    Quote Originally Posted by Elysia View Post
    This.

    You're being sour because clang actually traps your bugs, which no other compiler is able to. Deal with it. Fix it. Move on. I'd say it's retarded to rely on undefined behaviour.
    Add another to the disappointment list, and also the list of people who can't read.

  11. #26
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Then enlighten us as to the problem because from what I see the problem is very vague.

    From what I gather, you're complaining about how clang generates these trap instructions for undefined behaviour because they are messing up your code. And as the article says, they're generated because the compiler cannot always catch undefined behaviour at compile time. Are you trying to imply there's a bug that causes these instructions to trap when there's actually no undefined behaviour at all?
    Last edited by Elysia; 04-05-2016 at 12:05 PM.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  12. #27
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    Quote Originally Posted by Elysia View Post
    Then enlighten us as to the problem because from what I see the problem is very vague.

    From what I gather, you're complaining about how clang generates these trap instructions for undefined behaviour because they are messing up your code. And as the article says, they're generated because the compiler cannot always catch undefined behaviour at compile time. Are you trying to imply there's a bug that causes these instructions to trap when there's actually no undefined behaviour at all?
    I'd argue that, because it is emitting a UD2, it does know about the undefined behavior at build time, and should be able to emit a diagnostic.
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  13. #28
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,398
    Quote Originally Posted by Elkvis View Post
    I'd argue that, because it is emitting a UD2, it does know about the undefined behavior at build time, and should be able to emit a diagnostic.
    You haven't explained what your problem is with the presence of these UD2 instructions. Do you not test your code?

    EDITED: thought it was Epy I was replying to.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  14. #29
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Does it know about loop bounds that can be read from the user? Does it know 100% for sure that all function pointers will be initialized before use? Sometimes a compiler just can't do enough static analysis because a) it takes too long time or b) because it's too complicated or c) because it depends on how the code executes in runtime (e.g. dependencies on user input), so the compiler just can't tell if it's undefined behaviour or not. Sometimes it's also just too verbose, such as decisions it makes when optimizing. That's why it's emitting those instructions. To trap undefined behaviour at runtime when it can't guarantee things at compile time. That article posted before was really insightful. It really also points out why clang does as it does.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  15. #30
    Make Fortran great again
    Join Date
    Sep 2009
    Posts
    1,413
    Quote Originally Posted by Elysia View Post
    Are you trying to imply there's a bug that causes these instructions to trap when there's actually no undefined behaviour at all?
    Yes.

    Re-read everything I wrote and tell me what is more likely:
    a) Clang is the only compiler on the planet that can supposedly catch this mysterious undefined behavior, uncatchable by its own sanitizers and -Weverything, which apparently has been ignored/uncaught by numerous other compilers, static analyzers, and professional/open-source software developers since the early 1990s.
    b) These other compilers, GCC, MSVC, Intel C++, etc., all serious, production-level compilers, process this code without major warnings/errors and produce binaries that work as intended/expected, and have for years because the code is "correct" (enough). OCE is definitely not perfect, but at most is guilty of type punning in terms of undefined behavior. Thing is, what crashes does not correlate with where the type punning takes place in the code.


    Also, whats with the "your"? Again, this is code developed by professionals, professionals with graduate degrees in CS, not just anyone can program a CAD kernel.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Visual C++ .NET Quake 3 Source Port
    By bengreenwood in forum Game Programming
    Replies: 0
    Last Post: 03-16-2012, 08:02 PM
  2. Problem building Quake source
    By Silvercord in forum Game Programming
    Replies: 16
    Last Post: 07-11-2010, 09:13 AM
  3. Understanding something in Quake 2 Source Code
    By bengreenwood in forum C Programming
    Replies: 5
    Last Post: 08-05-2009, 02:22 PM
  4. Understanding a Line of Quake 2 Source Code
    By bengreenwood in forum C++ Programming
    Replies: 6
    Last Post: 08-04-2009, 03:15 PM
  5. Replies: 3
    Last Post: 05-08-2004, 10:58 AM