Thread: boolean operators question

  1. #31
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    @Syndacate: I don't know why you keep saying you write nothing of optimization when you write this:
    I mean sure, you can put a volatile keyword there as you did, and there's the possibility that it changes between checks, but the likelihood of a context switch occurring between checking two variables is almost 0 - and I'm sure that on some compilations it probably is 0 simply due to the way the compiler resolves the logic for the jump command itself.
    (Emphasis mine.) What else do you think that is, other than a compiler cheating (i.e., doing something it is specifically forbidden by the standard to do for the sake of saving time)?

    (ETA: And in terms of volatile, most people don't see memory-mapped i/o a la http://en.wikipedia.org/wiki/Duff%27s_device anymore but you can find that the act of reading a volatile variable is actually what changes its value.)
    Last edited by tabstop; 07-30-2011 at 03:08 PM.

  2. #32
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Syndacate View Post
    I'm actually having an argument with both of them because this is a continuation of an active conflict with both of them from another thread.
    You must have me confused with someone else, or at least you didn't make the same impression on me that I apparently made on you.
    Quote Originally Posted by Syndacate View Post
    It's simply an issue that this is a continuation argument of a prior thread. This is why neither of them have anything to say to the OP, just me.
    No it isn't. His question had already been answered by the time I saw the thread. You however, were wrong, were corrected, and had a fit about it.
    Quote Originally Posted by Syndacate View Post
    So in this case it's not a matter of correctness as much as it is a personal issue. I told them to take it to PM, but that failed.
    I notice that you didn't take it to PM either. Hypocrite. You are not only a hypocrite, but a liar. You didn't tell me to take anything to a PM.
    Quote Originally Posted by Syndacate View Post
    Ctrl + F is your friend, use it, learn it, know it, shut it.
    There there junior, no need to break into tears.
    Quote Originally Posted by Syndacate View Post
    I was speaking simply of the evaluation of it, NOT optimization.
    ...
    No, it's not optimization, it's simply evaluation. There doesn't have to be ANY optimization what-so-ever in the compiler, but depending on the ISA, and how the compiler was written, there exists the possibility that there is 0% chance of a context switch.
    ...
    Part of the ISA is the programmer visible registers...which are accessible from the assembly language...which is also defined by the ISA...which is all software. You're right, I didn't say anything about hardware, I simply mentioned the evaluation of the compiler. It's not optimization, it's called a "completely independent variable" - sort of like what is actually in a statement when you form a response to it.
    I believe you to be wrong on all accounts here. Until you prove otherwise, the standard I quoted seems to imply that you are wrong as well. Unless you can point out otherwise, this one is all me.
    Quote Originally Posted by Syndacate View Post
    When I said "at once" I meant during the check of the if statement. I should have clarified knowing who I was talking to...but if I remembered who you were at the time, I wouldn't have even bothered responding. You're way too hung up that you completely failed to answer a question to act like anything but a jackass.
    I have already proven you wrong here with the keyword volatile. Until you can prove otherwise, again, this one is all me.
    Quote Originally Posted by Syndacate View Post
    Evaluation, NOT optimization. When I said "how it puts things together" - I meant evaluation, again, this goes back to me should have knowing who I was talking to.
    Once again, what you are calling "evaulation" is really optimization. How the "compiler puts it together" - which is the direct quote the quote I am replying to replied to - specifically said that phrase. You are talking about the compiler optimizing the if check. Now you are mad because it makes you wrong, so you are trying to use different wording to be right. It doesn't work that way.
    Quote Originally Posted by Syndacate View Post
    No, it just means you have too much time on your hands.
    Translation: Quzah proved me wrong, now I'm mad and I'm going to go have a pout.
    Quote Originally Posted by Syndacate View Post
    I understand the concept of a volatile variable, but never-the-less, again, for the 47,000th time, I never said anything about optimization. So no, it doesn't mean you're right. It means you're misinterpreting everything, like usual.
    How "the compiler puts everything together" (your word) is optimization. It's not going to evaluate the loop ("evaluation" to use your word) and "and I'm sure that on some compilations it probably is 0 simply due to the way the compiler resolves the logic for the jump command itself." (your words - that's called optimization!)

    The compiler deciding what not to include is called optimization. Now be a good little idiot and go back and read the standard where it talks about not optimizing out volatile items.


    Quzah.
    Last edited by quzah; 07-30-2011 at 04:35 PM.
    Hope is the first step on the road to disappointment.

  3. #33
    Registered User
    Join Date
    Aug 2010
    Location
    Rochester, NY
    Posts
    196
    Quote Originally Posted by CommonTater View Post
    Methinks you caught the fallout from a bruised ego here and I do hope you understand that in "coder culture" bluntness is actually encouraged as a means of very concise communication (the programming language is equally unforgiving). I wouldn't let this bother you as it takes some people a while to get used to it... When people here come out with "You're wrong"... they're not attacking you, they're actually trying to help you be a better programmer, so keep that in mind....

    As for wanting a good grasp of an awkward part of the language, absolutely, you should understand one thing before you move on to the next and yes, I agree you're going about this the right way. However; If I'm allowed a suggestion here... you would get better mileage out of trying these things for yourself --as in compile and test all the examples and quizzes in the book-- using us as your backup. If you get a result you aren't expecting and can't sort out on your own... We'll be more than happy to tell you how wrong you are
    Not really, I have no ego. Though you are most certainly right in that it's the fallout here from a bruised ego. Quzah's ego is bruised because I felt he didn't answer anything that had to do with my question. He's all pouty because he's so arrogant that he feels he can't misunderstand something and be completely flat out wrong, like he was, when answering a thread. Notifying the OP of things that he OP said is NOT answering a question, in my book, sorry, it just isn't.

    I do agree, though, the OP should be learning by doing, which is why I suggested he moves on, instead of getting too hung up in the actual boolean logic part of it. Things will become more clear as he uses it in practice, writing code that does other things, than focusing directly on it, IMO.

    Quote Originally Posted by CommonTater View Post
    So, we should take it then, that you are willing to trample all over a thread --ignoring the OP's topic and questions-- simply because you lack the self-control and common sense to put down your stick and walk away?

    You may want to give this a whole lot more thought!
    Probably not, but then again, in my FIRST response to Aubril, I said this should be taken to PM, and NOT in the OP's thread. So A) That was attempted already, and B) This is a two sided issue, so please spare me the one sided attack. I don't care how you split it, it takes two to form a two way argument.

    Quote Originally Posted by tabstop View Post
    @Syndacate: I don't know why you keep saying you write nothing of optimization when you write this:

    (Emphasis mine.) What else do you think that is, other than a compiler cheating (i.e., doing something it is specifically forbidden by the standard to do for the sake of saving time)?

    (ETA: And in terms of volatile, most people don't see memory-mapped i/o a la Duff's device - Wikipedia, the free encyclopedia anymore but you can find that the act of reading a volatile variable is actually what changes its value.)
    The reason you don't understand how I'm saying that when I write things like that, is because you're misinterpreting what I'm saying.

    It's not compiler optimization in the least.

    Say you have an ISA for some architecture, architecture X, which does not support mid-instruction interrupts, which contains an instruction: "jmpifbool" - which is a variable length instruction (and yes, variable length instruction machines have existed) which is represented by a series of comparisons, each comparison separated by an operation, followed by an address, that is: jmpifbool 2 0 0 1 0 0 0x28282444, if '1' represented an AND, and 0 represented an equality comparison, and if the ISA respected an operator precedence, then a C compiler for architecture X, can look at an if statement in the code, say for instance:
    Code:
    if (x == 5 && x == 15) ..
    And write the following instruction to correspond to that, saying x = 3 at the time the of execution, stored in register r2, and the jump location is stored in register r4.
    Code:
    jmpifbool r2 0 5 1 r2 0 15 r4
    Now if that one instruction was created, then simply due to the way the ISA is crafted, there exists 0 percent chance that when the compiler evaluates the expression, if x was a volatile value, could change. That's all I meant, not sure where everybody is getting the term "optimized" from, I simply said there exists the possibility that due to the way an ISA is designed, there may actually be a 0% chance of that happening. And since you can't develop every single ISA possible (infinite permutations of variables), then it's literally IMPOSSIBLE for any of you to say there isn't a chance that there's a 0% chance of x being modified between the two 'operations' - as they exist in C code.

    Now, while this example is embellished to make my point, the fact is that there exists the possibility for a compiler, without optimization, to evaluate that expression in a manner in which the volatility of the x variable, would not matter in that particular example, creating a 0% chance that it is changed.

    I hope that clears things up for you guys.

    Quote Originally Posted by quzah View Post
    You must have me confused with someone else, or at least you didn't make the same impression on me that I apparently made on you.
    Possibly, but when I said that I didn't feel your answer answered my question in the slightest, Aubril started attacking me, saying I was being 'curt' - you know, because displaying emotions is just THAT easy in text. Then that fiasco spilled into here and what a surprise, now you both are jumping on my dick about stuff in here, too. I only suspect that this trend will continue until you/him get over what I said.

    Quote Originally Posted by quzah
    No it isn't. His question had already been answered by the time I saw the thread. You however, were wrong, were corrected, and had a fit about it.
    Or rather. I was wrong, was corrected, fixed it, and mentioned that he's not going to get off my back about the last thread, is he? To which the answer is quite obviously: No

    Quote Originally Posted by quzah
    I notice that you didn't take it to PM either. Hypocrite. You are not only a hypocrite, but a liar. You didn't tell me to take anything to a PM.
    You are 100% right. By me telling you guys to take it to PM, then when you guys started in, I continued by responding in the thread, I was indeed hypocritical. For this, I apologize. Also, you're right, I didn't tell you directly to take it to PM, I only told Aubril, I would have thought you'd put 2 and 2 together and figure out that that means you should probably take your issues to PM, as well...but I guess not.

    Quote Originally Posted by quzah
    I believe you to be wrong on all accounts here. Until you prove otherwise, the standard I quoted seems to imply that you are wrong as well. Unless you can point out otherwise, this one is all me.
    Okay. Read my response above to tabstop, pointed out otherwise.

    On the flip-side I'd like to see ANY of you guys prove that there can't exist an ISA where the compiler's base evaluation of boolean logic disallows the possibility of the variable changing. Since there's an infinite combination of components to make a processor and an ISA, it's impossible for ANY of you guys to prove that there can't. While not real, the above situation I described, can very well be written as a soft proc on an FPGA or something. That would be a processor, and a compiler, that has absolutely NO optimization, but the constructs of the instructions for the processor simply don't allow that to happen due to their nature. Nothing to do with optimization, same way a Linux box strike(can't) (is UNLIKELY to) get a root-kit developed for a Windows software stack. Doesn't have anything to do with the security, it simply can't due to the nature of the way the software stacks were developed.

    I'm talking about things that are attributes of the actual system design, done without optimization in mind, just the way they're set up, that's why I feel they're not optimizations.

    Like if an architecture doesn't allow DMA, then it's not possible for the 1394 exploit to work - that's not a security feature, that's just intrinsic to it not having DMA.

    Hope that clears up what I meant.

    Quote Originally Posted by quzah
    Once again, what you are calling "evaulation" is really optimization. How the "compiler puts it together" - which is the direct quote the quote I am replying to replied to - specifically said that phrase. You are talking about the compiler optimizing the if check. Now you are mad because it makes you wrong, so you are trying to use different wording to be right. It doesn't work that way.
    I'm not trying to slant my wording to be right, see above. How the compiler puts things together to me is NOT optimization. If I was writing a compiler, I would start with no optimizations, just evaluation. Then, once completed, I would add optimization features in, patterns to look for, etc. Though in between those two states, the compiler is not optimizing anything, it is simply evaluating. Now, as I've described above, if the ISA the compiler is compiling for intrinsically doesn't allow the volatile variable to be modified, as it doesn't support context switching mid-instruction, then my claim that it's indeed possible to have a 0% probability there, still stands.

    Quote Originally Posted by quzah
    Translation: Quzah proved me wrong, now I'm mad and I'm going to go have a pout.
    No, actually I don't even see what part of you quoting the c-spec "proved you were right" - but then again, I don't quite get/care what you're ranting on about being right about, so I didn't bother to address it then, and I'm not bothering now. The above proves my point, and that's all I care about, I have no interest in whether you're right or wrong, that's your concern, mine is simply to illustrate my point, the above gives you an example. If you want to prove that what I said is wrong, find a way to deduce that there can't exist an ISA that intrinsically has a 0% probability of that scenario evaluating it to true simply because the volatile keyword was in there. This is outside of the realm of the C-spec, IMO. There's a difference in saying that the compiler can't perform operations on a given variable, and the C-spec dictating what the HW must look like. The above example can very well meet the volatile requirements, defined in the c-spec, but it also leaves a 0% chance of the scenario happening.

    Quote Originally Posted by quzah
    How "the compiler puts everything together" (your word) is optimization. It's not going to evaluate the loop ("evaluation" to use your word) and "and I'm sure that on some compilations it probably is 0 simply due to the way the compiler resolves the logic for the jump command itself." (your words - that's called optimization!)

    The compiler deciding what not to include is called optimization. Now be a good little idiot and go back and read the standard where it talks about not optimizing out volatile items.
    So what happens if you use a compiler with all optimizations disabled? It's still optimization in your book? That's plain and simple evaluation of the expressions, in mine..if it's not optimizing it's not optimizing. I never said anything about the compiler deciding not to include, that would INDEED be optimization, but as I said 1000 times, I'm not talking about optimization.

    Again, see above, a compilation as the machine described with absolutely no optimizations completely backs the quote I said, which you quoted, and would require absolutely no optimizations from the compiler to leave you with a 0% chance of the original scenario happening, while still upholding the specification of the volatile keyword described in the c-spec.
    Last edited by Syndacate; 07-30-2011 at 07:23 PM. Reason: Fixed wording to make it more clear.

  4. #34
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by Syndacate View Post
    And write the following instruction to correspond to that, saying x = 3 at the time the of execution, stored in register r2, and the jump location is stored in register r4.
    Code:
    jmpifbool r2 0 5 1 r2 0 15 r4
    This statement is false. The compiler is quite simply not allowed to generate such an expression by the rules of the language. If it does, it is reading some other language than C. (ETA: In the language of C syntax, && generates a "sequence point", which means that everything on the left side must be completely and totally finished before the right side starts; there can be no combining of any kind.)

  5. #35
    Registered User
    Join Date
    Aug 2010
    Location
    Rochester, NY
    Posts
    196
    Quote Originally Posted by tabstop View Post
    This statement is false. The compiler is quite simply not allowed to generate such an expression by the rules of the language. If it does, it is reading some other language than C. (ETA: In the language of C syntax, && generates a "sequence point", which means that everything on the left side must be completely and totally finished before the right side starts; there can be no combining of any kind.)
    Yes, it would evaluate to false, the jump would not be taken.

    I've never heard of this idea of sequence points, I've never heard anything about that concept. I'll look into it and get back to you.

    Though I still stand by my claim that it's impossible to say there CAN'T be an ISA/Compiler in which this the above is intrinsically not an issue, simply because it's not a possible proof to make.

  6. #36
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Syndacate View Post
    I've never heard of this idea of sequence points, I've never heard anything about that concept.
    So you didn't bother reading the C standard I quoted at you earlier is what you are saying.
    Quote Originally Posted by Syndacate View Post
    Though I still stand by my claim that it's impossible to say there CAN'T be an ISA/Compiler in which this the above is intrinsically not an issue, simply because it's not a possible proof to make.
    Not if you want it to be an ANSI C compliant compiler, no. I've already told you why, which according to the above quote, you didn't bother reading.
    Quote Originally Posted by the standard, 6.7.3.6
    An object that has volatile-qualified type may be modified in ways unknown to the implementation or have unknown side efects. Therefore any expression referring to such an object shall be evaluated strictly according to the rules of the abstract machine as described in 5.1.2.3. Furthermore, at every sequence point the value last stored in the object shall agree with that prescribed by the abstract machine, except as modified by the unknown factors mentioned previously.* What constitutes an access to an object that has volatile-qualified type is implementation-defined.
    Nice job slick. So for all that blustering you did about me not reading anything ... hypocrite.


    Quzah.
    Hope is the first step on the road to disappointment.

  7. #37
    Registered User
    Join Date
    Aug 2010
    Location
    Rochester, NY
    Posts
    196
    Quote Originally Posted by quzah View Post
    So you didn't bother reading the C standard I quoted at you earlier is what you are saying.
    Quote Originally Posted by quzah
    Not if you want it to be an ANSI C compliant compiler, no. I've already told you why, which according to the above quote, you didn't bother reading.
    Quote Originally Posted by quzah
    Nice job slick. So for all that blustering you did about me not reading anything ... hypocrite.
    While I did read it, I guess I didn't draw the correlation between what I was trying to say, and the standard you posted...like most posts between you and I.

    The machine I described most certainly does fail due to that requirement in the standard. Though I'll still stick by my original opinion, which as you quoted to be: "and I'm sure that on some compilations it probably is 0 simply due to the way the compiler resolves the logic for the jump command itself."

    Since it's impossible to create every type of ISA, one can NOT say for sure if a machine can exist in which a compiler, with no optimizations, would leave a 0% probability for the variable to change, while still respecting both the volatile keyword and the sequence points defined in the c std; therefore, I'll say that I'm sure that on some compilation(s) the chance is probably 0 simply due to the way logic is evaluated.

    I'm not arguing with you - I'm defending a point I made. If you want to break my point, prove to me that it's wrong. To do so, create every ISA possible, taking into account the infinite number of variables necessary. Then, I will say "ok, my statement was wrong."

  8. #38
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    quzah, have to poke the bear huh?

    It is quite clear that syndacate is not knowledgeable of the C standard or what that means. His talks always refer to this hypothetical "ISA/Compiler", when was the last time you had that discussion? Some intro to software development course where instruction sets are introduced and they explain the pros and cons of high level languages, wait I will stick with the linguo "HLLs".

    So, to sum this up, yes just about anything is possible however in C you are limited to what the standard says. Otherwise it isn't C. Plain and simple.

    Maybe the MODS SHOULD MOVE THIS THREAD TO THE GENERAL DISCUSSION BOARD BECAUSE IT DOESN'T BELOW IN THE C BOARD.

    EDIT: Syndacate, this is the C BOARD. Thus, anything you post here will be evaluated against the C standard.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  9. #39
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Syndacate View Post
    I'm not arguing with you - I'm defending a point I made. If you want to break my point, prove to me that it's wrong. To do so, create every ISA possible, taking into account the infinite number of variables necessary. Then, I will say "ok, my statement was wrong."
    If you don't want to be compatible with the C standard, you can make your compiler do whatever you want. If you want to optimize out--sorry, evaluate out--volatile items, go ahead. Just don't be surprised when I say you aren't using standard C anymore, and as such, are off in your own little universe that I will completely disregard.


    Quzah.
    Hope is the first step on the road to disappointment.

  10. #40
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Quote Originally Posted by quzah View Post
    If you don't want to be compatible with the C standard, you can make your compiler do whatever you want. If you want to optimize out--sorry, evaluate out--volatile items, go ahead. Just don't be surprised when I say you aren't using standard C anymore, and as such, are off in your own little universe that I will completely disregard.

    Quzah.
    Yes. I have my new quote, thank you quzah.
    LOL...

    EDIT: SEE BELOW
    Last edited by AndrewHunter; 07-30-2011 at 08:21 PM.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  11. #41
    Registered User
    Join Date
    Aug 2010
    Location
    Rochester, NY
    Posts
    196
    I've made the point too many times to count, this is my last post in this thread, and I won't continue this BS in other threads:

    I'm sorry that the last time you heard of ISA's was in an intro to software development course...unfortunately they extend way beyond that.

    But as far as this:
    Quote Originally Posted by AndrewHunter
    So, to sum this up, yes just about anything is possible however in C you are limited to what the standard says. Otherwise it isn't C. Plain and simple.
    I'm just going to say what I've said before:
    Quote Originally Posted by Syndacate
    Since it's impossible to create every type of ISA, one can NOT say for sure if a machine can exist in which a compiler, with no optimizations, would leave a 0% probability for the variable to change, while still respecting both the volatile keyword and the sequence points defined in the c std; therefore, I'll say that I'm sure that on some compilation(s) the chance is probably 0 simply due to the way logic is evaluated.
    When you prove the above, then I'll take a look back here. Until then, I'm done posting here, and I'm done arguing about this crap in other threads.

  12. #42
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by Syndacate View Post
    I'm not arguing with you - I'm defending a point I made. If you want to break my point, prove to me that it's wrong. To do so, create every ISA possible, taking into account the infinite number of variables necessary. Then, I will say "ok, my statement was wrong."
    No one's denying that the instruction can exist (in fact it wouldn't surprise me if it does, somewhere; if some chipmaker thinks it's a good idea, it's going to be in the chip). You just can't use it, when making a C compiler (unless you are sacrificing correctness for speed, also known as ... well, never mind).

    EDIT: In other words, proving this statement wrong does not require building an ISA at all. It requires reading the C standard, which states that the value of a volatile variable cannot be "carried over" across a sequence point; thus any compilation that does so is in violation of the standard (whether by bug, by not caring, or otherwise is up to your conscience).
    Last edited by tabstop; 07-30-2011 at 08:27 PM.

  13. #43
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Syndacate View Post
    When you prove the above, then I'll take a look back here. Until then, I'm done posting here, and I'm done arguing about this crap in other threads.
    You want me to prove your case? You don't know much about having a debate, do you? It's probably for the best that you've decided to run along.


    Quzah.
    Hope is the first step on the road to disappointment.

  14. #44
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Good lord... Quzah... Syndacate .... Get a Room!

    Really...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help on Boolean Operators?
    By yosimba2000 in forum C++ Programming
    Replies: 2
    Last Post: 12-01-2009, 09:58 PM
  2. Boolean Operators...
    By Nean in forum C++ Programming
    Replies: 8
    Last Post: 10-06-2009, 02:31 AM
  3. boolean operators
    By forkpie hat in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2008, 03:35 AM
  4. Quick question on Boolean operators
    By gn17 in forum C Programming
    Replies: 7
    Last Post: 08-12-2007, 10:43 PM
  5. Boolean operators
    By Trogdor27 in forum C++ Programming
    Replies: 10
    Last Post: 09-12-2005, 06:46 AM