6 ms·
Well, without concrete examples this just sounds childish TBH. But I haven’t looked very closely at it myself, hence the afaik qualifier.
by krig 1y ago
Well, without concrete examples this just sounds childish TBH.
But I haven’t looked very closely at it myself, hence the afaik qualifier.
- tialaramex 1y agoSo as a concrete example: https://odin.godbolt.org/z/8onn4hxP1 https://odin.godbolt.org/z/8onn4hxP1 This brief example makes a hash map, then it demonstrates that if we call a sub-routine which makes its own distinct hash map, that doesn't change ours, but, once we destroy our hash map and call the sub-routine again, we can still use the variable for our (destroyed) hash map (!) but doing so reveals the contents of that other hash map from the sub-routine instead in the cases I saw. Now, in C or C++ if you do this that's Undefined Behaviour and the symptoms I saw (and which you're likely to see if you follow the link) are just one of arbitrarily many ways that could manifest. In Rust of course the equivalent code won't compile because the hash map is gone so we can't just go around using it after that. And in Odin, well, as Ginger Bill has explained Odin does not have Undefined Behaviour so... this has behaviour which er, Odin has not defined ? Does that make you feel warm and tingly or do you feel like Bill just wasted time arguing semantics?
- krig 1y agoWell, sure. If that’s what you mean by having UB then it’s trivially true for any language with a C FFI for example, or rust with unsafe. I guess what I consider UB is when the compiler exploits UB for optimizations, like discarding code that could invoke UB, which as far as I know odin doesn’t do.
- jibal 1y ago> I guess what I consider UB is when the compiler exploits UB for optimizations, like discarding code that could invoke UB, which as far as I know odin doesn’t do. This statement is incoherent. UB is undefined behavior, and it existed long before any compiler exploited it and isn't (circularly) defined by whether the Odin compiler exploits it.
- krig 1y agoWell, the statement is circular, colloquial speech doesn't have to be coherent. It's my understanding of what people generally mean when they complain about UB in the C standard, and it seems to be what gingerbill means too. My take on what he is saying is that the odin compiler won't try to exploit that there is some behavior which is platform-defined or only knowable at runtime to do aggressive optimizations etc. https://xcancel.com/TheGingerBill/status/1495004577531367425 https://xcancel.com/TheGingerBill/status/1495004577531367425 To point out that use after free is possible in Odin is not really a gotcha unless you really are just arguing semantics. That's by design, just like use after free is possible in C or C++ or Rust too.
- jibal 1y agoYour understanding is completely wrong. UB means "undefined behavior" -- behavior that is not specified by the language standard or the implementation. UB being exploited by the compiler is a separate issue. Saying that there is no UB is saying that there's no undefined behavior; it is certainly not merely saying that the compiler doesn't exploit it. I programmed in C for over 30 years and was a member of the C Standards Committee, which originated the language about undefined behavior ... I know what I'm talking about. > To point out that use after free is possible in Odin is not really a gotcha unless you really are just arguing semantics. That's by design, just like use after free is possible in C or C++ or Rust too. This completely misses the point and is a failure to understand at every level. Being able to use memory after being freed is not by design -- no one intends it, no one wants it. It's undefined behavior, and a program that does it is buggy. The reason that it's possible is because it's so hard to detect or prevent. To do so requires escape analysis, lifetime declarations, borrow checking, etc. etc. And no, use after free is not possible in Rust--not in safe code. It's hard to respond to that statement without being rude, so I will say no more.
- krig 1y agoWell, first of all, I guess I am wrong! Hey, I'm not Bill, just a user of the language. A couple of clarifications, though: I did mean unsafe rust, not the safe subset. No need to get rude! Second of all, I am of course not under the illusion that Odin prevents use-after-free (and thus, technically, it does allow UB I guess). I just don't think Bill is either. So clearly he doesn't mean UB by the same definition as you do. _My_ use of UB has always been in the context of what a compiler will do during optimization, and the discussion I've seen in the context of C compilers is that they perform optimizations that remove code or change code in surprising ways because the way the code was written technically resulted in UB. But I'm neither a spec writer or a compiler author, so I don't really care that much about the actual definition of the term. Anyway, best of luck in convincing Bill to use the term correctly as well! I won't mention UB when talking about the benefits of Odin in the future. :)
- ixwt 1y agoThis is a simple use after free on the stack. Is that UB?
- jibal 1y agoYes, of course ... the content of freed memory, on the stack or otherwise, is not defined. (And this is not in fact on the stack.)
- ixwt 1y ago1. I'm fairly certain you have to use make to get into heap. 2. Odin 0s out memory when declaring a variable unless you explicitly state so with ---. This defines the state of memory when allocated.
- tialaramex 1y agoOrdinarily you'd be correct that you need the weird make overload, but I had no cause to invoke make I just told Odin that we don't care and it's fine, check the first line. Whether that feature is a good idea in this language I couldn't say. Odin's decision to zero initialize local variables isn't relevant here.
- ixwt 1y agoHuh. Wasn't aware of that feature. Good to know. I didn't fully flesh out the initializing local variables: What part of your code is undefined? You deleted the memory, and the compiler reused it. Then you re-accessed that same memory. That's just part of working with computers. The initialization comment was supposed to be from creating data to releasing it is defined. To be compliant with the Odin compiler spec, it's defined from start to end.
- SkiFire13 1y agoNot OP but: > What part of your code is undefined? Using a variable (`some_map` in this case) after `delete`ing it doesn't seem something languages usually define in their specification. Does Odin define that?
- jibal 1y ago> Well, without concrete examples this just sounds childish TBH. Please don't be pointlessly insulting. The description matches many people's experience.
- krig 1y agoI'm not the one throwing baseless accusations around. "He was mean to me once" isn't that interesting, especially without anything concrete to back it up.
- jibal 1y agoFirst, that's whataboutism. Second, you are, actually. And what the other fellow said is not at all baseless, and he did back it up. GB is well known for being argumentative, highly opinionated, and rude. But people make allowances for those who put in the work, and GB certainly does.
- gingerBill 1y agoMe being "well known" in general is news to me. However, the people I am that way are usually people like yourself. I am argumentative with people like yourself, however I try not to be "rude" but I am not always "nice". I think this is probably a cultural distinction where I make a distinction between Niceness and Politeness. Rudeness is the not-being-polite, rather than not-being-nice. As for my "highly opinionated" things, honestly, I don't think I am that opinionated about many things, but I guess the ones I am on, they are the "well known" aspects. If I am wrong about something, I will gladly change my opinion given a good argument or set of facts.
- krig 1y agoFirst, no it isn't. What baseless accusation did I make? I haven't seen the conversations he is referring to, he didn't link to or quote anything. It's just some general complaint about Bill, which may be true but who cares?
- 1y ago