- Functions and the linker - 5 Updates
- OT: Association for Orthodox Jewish Scientists - 1 Update
- C - 1 Update
legalize+jeeves@mail.xmission.com (Richard): Mar 17 08:42PM [Please do not mail me a copy of your followup] Paavo Helde <myfirstname@osa.pri.ee> spake the secret code >Sorry, I am not sure I am understanding what you wanted to say. An >odr-use of a name that is not defined is exactly what constitutes the >undefined behavior [...] I'm not sure how this constitutes undefined behavior, because the ODR rule says essentially that everything you use has to be defined. If you're just concluding "its UB because it doesn't say anything about it", then we have to go through the entire standard to draw that conclusion. >non-inline odr-used function. The programs which contain 2 or 0 >definitions of such a function are not covered by the standard, i.e. >their behavior is undefined. This just seems like an awfully broad definition of UB with respect to the ODR rule. Or perhaps it is just silly to do anything other than give a link error for symbols that are multiply defined or undefined when the ODR is broken. Hell, gcc ran nethack at one point, so while the compiler is technically free to do whatever it wants during undefined behavior, letting such undefined symbols slip through without an error feels highly unuseful. -- "The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline> The Computer Graphics Museum <http://computergraphicsmuseum.org> The Terminals Wiki <http://terminals.classiccmp.org> Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com> |
legalize+jeeves@mail.xmission.com (Richard): Mar 17 08:43PM [Please do not mail me a copy of your followup] Alain Ketterlin <alain@universite-de-strasbourg.fr.invalid> spake the secret code >Document Number: N4296, Date: 2014-11-19, available from >https://isocpp.org/std/the-standard >Which has section 5.20 ("Constant Expressions"), on page 132. I was using N3797, so looks like I need to get an updated draft. Thanks. -- "The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline> The Computer Graphics Museum <http://computergraphicsmuseum.org> The Terminals Wiki <http://terminals.classiccmp.org> Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com> |
Paavo Helde <myfirstname@osa.pri.ee>: Mar 17 10:48PM +0200 On 17.03.2016 22:18, Alain Ketterlin wrote: > bool s2 = s; > then it compiles & links. The strange behavior is due to the conversion > to bool. So, conversion to a bool is "an lvalue-to-rvalue conversion", but conversion to a function pointer is not? Or is it that the first is a "constant expression", but the second is not? I'm more confused than before. Section 5.20 contains word 'bool' only in an unrelated example code piece. And section 4.12 (Boolean conversions) talks only about pointer to bool conversions, so it seems in order to be converted to bool the function needs to be converted to a pointer first anyway. How comes a program that contains an extra conversion (pointer-to-bool) does not contain UB while the program without this additional conversion has UB? Cheers Paavo |
Paavo Helde <myfirstname@osa.pri.ee>: Mar 17 11:10PM +0200 On 17.03.2016 22:42, Richard wrote: >> their behavior is undefined. > This just seems like an awfully broad definition of UB with respect to > the ODR rule. This has nothing to do with the ODR rule, it's a general property of the standard (and many other standards no doubt). <quote> 1.3.24 [defns.undefined] undefined behavior behavior for which this International Standard imposes no requirements [ Note: Undefined behavior may be expected when this International Standard omits any explicit definition of`behavior [...]. Many erroneous program constructs do not engender undefined behavior; they are required to be diagnosed. </quote> Coming back to the ODR rule, this is specifically mentioned as not to be required to be diagnosed ("no diagnostic required"). I guess this is so because the linker (which would be able to diagnose such errors) might not be under the control of the compiler developers. > the compiler is technically free to do whatever it wants during > undefined behavior, letting such undefined symbols slip through > without an error feels highly unuseful. The program works exactly the same as it would have worked when the function had been defined, so I am not sure there is a good reason to blame gcc here. On the other hand, there is no good reason to blame MSVC either for not compiling the program. Cheers Paavo |
Alain Ketterlin <alain@universite-de-strasbourg.fr.invalid>: Mar 18 12:02AM +0100 Paavo Helde <myfirstname@osa.pri.ee> writes: [...] > So, conversion to a bool is "an lvalue-to-rvalue conversion", but > conversion to a function pointer is not? Or is it that the first is a > "constant expression", but the second is not? I think because the first is a constant expression. > conversions) talks only about pointer to bool conversions, so it seems > in order to be converted to bool the function needs to be converted to > a pointer first anyway. Actually, I was refering to 3.2 ("One definition rule"), §3: "A variable x whose name appears as a potentially-evaluated expression ex is odr-used by ex unless applying the lvalue-to-rvalue conversion (4.1) to x yields a constant expression (5.20) that does not invoke any non- trivial functions [...]" So the name is a constant expression after lval-to-rval conversion, and it is not odr-used. After this, implicit standard conversions (Clause 4 [conv]) apply, especially (4.12) to convert to bool, and since the name cannot be nullptr_t, the result of the conversion is true. > How comes a program that contains an extra conversion > (pointer-to-bool) does not contain UB while the program without this > additional conversion has UB? Clause 4 starts with: "Standard conversions are implicit conversions with built-in meaning." And (5.20) notes: "Constant expressions can be evaluated during translation." Therefore, I see no UB, because there is no behavior at all... -- Alain. |
woodbrian77@gmail.com: Mar 17 03:55PM -0700 On Thursday, March 17, 2016 at 5:45:41 AM UTC-5, Juha Nieminen wrote: > indirectly want: To feel a victim of antipathy and hatred, because > that will bolster your sense of being alone against the big bad world. > It makes you feel special. I recall discussing Noah and the ark with you previously. Here's how Peter, one of Yeshua's (aka Jesus) disciples wrote about Noah: "For if G-d did not spare angels when they sinned, but cast them into hell and committed them to pits of darkness, reserved for judgment; and did not spare the ancient world, but preserved Noah, a preacher of righteousness, with seven others, when He brought a flood upon the world of the ungodly" 2nd Peter 2:4,5 I see a few similarities between myself and Noah -- I've also been working on a big project and I encourage righteousness. Noah's preaching wasn't very successful in terms of persuading people. Noah is faulted by some of the sages: G-d said to Noah . . . "Make yourself an ark" (6:13-14) G-d has many ways to save someone; why did He make Noah toil to build the ark? In order that the people of his generation should see him occupied with the task for 120 years, and they should ask him, "Why are you doing this?" and he would tell them that G-d is bringing a flood upon the world. Perhaps this would cause them to repent. (Rashi; Midrash Tanchuma) When G-d said to Noah, "The end of all flesh has come before Me," Noah said: "What will You do with me?" But he did not pray for mercy for the world, as Abraham would pray for the city of Sodom. . . . This is why the Flood is called "the waters of Noah" (Isaiah 54:9)-- he is culpable for them, because he did not appeal for mercy on the world's behalf. (Zohar) Noah tried to save his generation by calling on them to repent. But the fact that he did not pray for them implies that, ultimately, it did not matter to him what became of them. Had he truly cared, he would not have sufficed with "doing his best," but would have implored the Almighty to repeal His decree of destruction--just as a person whose own life is in danger would never say, "Well, I did my best to save myself" and leave it at that, but would beseech G-d to help him. In other words, Noah's involvement with others was limited to his sense of what he ought to do for them, as opposed to a true concern for their well-being. He understood the necessity to act for the sake of another, recognizing that to fail to do so is a defect in one's own character; but he fell short of transcending the self to care for others beyond the consideration of his own righteousness. This also explains a curious aspect of Noah's efforts to reach out to his generation. When the Flood came, Noah and his family entered the ark--alone. His 120-year campaign yielded not a single baal teshuvah (repentant)! Perhaps public relations was never Noah's strong point, but how are we to explain the fact that in all this time he failed to win over a single individual? But in order to influence others, one's motives must be pure; in the words of our sages, "Words that come from the heart enter the heart." Deep down, a person will always sense whether you truly have his interests at heart, or you are filling a need of your own by seeking to change him. If your work to enlighten your fellow stems from a desire to "do the right thing" but without really caring about the result, your call will be met with scant response. The echo of personal motive, be it the most laudable of personal motives, will be sensed, if only subconsciously, by the object of your efforts, and will ultimately put him off. (The Lubavitcher Rebbe) Yeah, so sadly I'm similar to Noah in terms of his weaknesses also. G-d knows that I'm often a mess of pride, lust and apathy. I'm paraphrasing something there from the band switchfoot -- www.switchfoot.com . > For your own sake, just start acting like a normal reasonable human > being. > --- news://freenews.netfront.net/ - complaints: news@netfront.net --- I admit to being a Yeshua (Jesus) Freak. G-d died for my sins and I owe everything to Him. I'm like the "living sacrifice" that Paul wrote about. Unfortunately, I have a tendency to crawl off of the altar -- to try to save myself. It doesn't work though. Depression and isolation are nothing new to the prophets and other biblical figures or to followers of Yeshua. "Many are the afflictions of the righteous ..." Salvation/rescue is also part of our story. I'm thinking about how Moses had led the Israelites out of Egypt and Pharoah pursued them with his army. The Israelites were pinned with their backs to a sea and Pharoah's chariots descending on them. G-d rescued their butts though and I'm here to rejoice over their victory and my victories over the powers of darkness. Ebenezer Enterprises is doing better than ever by the grace of G-d. I'm also happy to learn about Sinai and Synapses and want to give them a shout out for the work they are doing. Brian Ebenezer Enterprises - See quotes above. http://webEbenezer.net |
Jorgen Grahn <grahn+nntp@snipabacken.se>: Mar 17 09:25PM On Thu, 2016-03-17, Juha Nieminen wrote: > Merve Tekta?? <mervetektas1995@gmail.com> wrote: >> 1. Design an algorithm to print hello world to the screen. > Can that even be called and algorithm? Didn't I cover that yesterday? > Do you even know what an algorithm is? The sad part is that the guy who wrote the exercise (and possibly gets paid to teach this stuff) doesn't seem to know. /Jorgen -- // Jorgen Grahn <grahn@ Oo o. . . \X/ snipabacken.se> O o . |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment