Newsgroups: comp.arch Path: csiph.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!kithrup.com!mrs From: mrs@kithrup.com (Mike Stump) Subject: Re: The freedom that give us C++ and C Message-ID: Date: Sat, 6 Feb 2016 14:17:49 GMT References: <57634aea-89f5-4dae-9d2e-415c572b1ead@googlegroups.com> Organization: Kithrup Enterprises, Ld. X-Newsreader: trn 4.0-test77 (Sep 1, 2010) Lines: 77 Xref: csiph.com comp.arch:33520 In article , Megol wrote: >GCC already extend the C standard in ways that mean a GCC "C" program >that compiles and run in the expected way needn't be a "C" program >according to the C standard. If GCC can compile these nonstandard >programs while still being a "C" compiler then it could also compile >"C" sources in a manner where (for a given machine >architecture/environment) some things undefined in the standard can >be relied upon producing defined actions while still being a "C" >compiler. Right. It can be. >I just want the know-it-all to tell us how it is. Sure, it is undefined. To elaborate, gcc uses undefined as an indicator that the condition underwhich that code would execute, to not be the case. So, for example in: if (i == 1) printf("Hi\n"); else _undefined (); gcc knows that i is equal to 1. This is surprising. The compiled code would only ever print Hi, this too is surprising. This learned fact, is forward propagated and backwards propagated. I do realize that to most programmers, they might not understand or have any clue why we do this. Maybe they think that each construct just maps to an instruction, and that is that. In practice, we do much more. >> Even if you, like me, would find the implementation-specific thing that Anton >> Ertl would prefer to be what you would prefer as well, what C compilers ought >> to do when they're able, and not fail to do without a very good excuse... >> that's not a reason for misconstruing ... > >But that is exactly what Mr. Stump is doing! Not quite, our reason isn't a very good excuse _to him_. Indeed, it isn't even necessarily a very good excuse to us. We decide to do X or Y, and at the limit, we have to decide only based upon this is slightly better than that. And then, when we decide, it isn't based upon what one person wants (him), it is based upon total good. We decide total good, not him. We get to choose. I get to inform the loosers, they lost, they can't have what they want. It sucks, it hurts, it's life. He can whine about it endlessly, he can then say he hates gcc, hates C, and try and convert people to also hate. That's his right, his freedom of expression. The only problem with his view, is the absence that there could be a reason that others prefer the other solution. They do. Now, let me put it this way, if money were no object and efficiency didn't matter any and we had limitless ram, I don't think we'd have a leg to stand on. It is that we target high performance; that our users want performance. His point is, well, it is better to have slow code, I don't like performance enough to pay that price for it. If you have a computer that sucks down 10 MW, or has to fit on a phone, or must get 60 frames per second, or you want to double your profit and save some ram, gcc is a good choice, C is a good choice. But, part of that choice is learning how to use the tool. -O2 means go fast, you don't want that, don't ask for it. It will cost 10x (or so, today), if you don't. The choice is yours. His position isn't unreasonable, it just isn't what C compilers are (usually). Now, he _can_ get, what he wants, by using a flag (-fsanitize=undefined). This is how we try and get both parties to win simultaneously when one must loose. We punt to flags, switches, pragmas and the like. He chooses not to use the vended solution, not learn there is one, and to tirelessly whine. If he were sane, we would be using it, love it, and go on with life. If it missed something he wanted, he could file a bug report, and/or fix his code, no big deal. So far, he has failed to explain why, it is impossible for him to fix his buggy code. I cannot write code without bugs, because....