- Hardware advice - 2 Updates
- Clever or tidy code snippets - 7 Updates
woodbrian77@gmail.com: Mar 04 09:55AM -0800 Shalom As you may know I'm looking for some external users. Despite the lack of users, I'm thinking about buying parts and building a new server. I'll probably go with AMD Ryzen, but am trying to decide between AM4 or a threadripper TRX40. I've been leaning toward a TRX40, but recently thought maybe that's overdoing it since I'm still looking for some external users. I could still get a 16 core chip with the AM4 socket. Any suggestions on motherboards or power converters (aka psu)? I'm thinking about using Samsung NVMe SSDs for storage. They can be up to 2TB and I could have at least 3 of them. I've found pcpartpicker.com to be helpful in terms of estimating the power needed and informing me that something is missing. Is there another forum that focuses on this sort of thing? Thank you in advance. Brian Ebenezer Enterprise - Enjoying programming again. https://github.com/Ebenezer-group/onwards |
woodbrian77@gmail.com: Mar 04 10:44AM -0800 > that's overdoing it since I'm still looking for some > external users. I could still get a 16 core chip > with the AM4 socket. I'll at least be running FreeBSD on the server, but possibly Linux also due to it's better support for Wireguard at this time. The attraction of the TRX40 is to be able to serve all of my hopefully soon-to-be users with one machine. Between using C++ for my code generator from the beginning, finding ways to improve it over the years and the release of these Threadripper chips, I hope be able to use just one box and one backup box to handle everything. |
Maciej Sobczak <see.my.homepage@gmail.com>: Mar 04 12:39AM -0800 > It's fine in my case as I only need the string (which can be empty if the second program crashes). > while ( nullptr != fgets(buffer.data(), buffer.size(), pipe.get()) ) And what if the second program crashes in the middle of producing the output? Is the possibility to read partial (corrupted?) output acceptable for you? This code example is indeed neat, but also a bit deceptive. It makes provisions for the popen failing (and translates it into exception), but ignores the possibility of fgets failing sometime later (also by means other than EOF). It might be negligible in your particular case (the result might have some integrity features built in its syntax), but is worth being aware of before copy-pasting this code to some other arbitrary system. But it's true, custom deleters in smart pointers are indeed powerful. :-) -- Maciej Sobczak * http://www.inspirel.com |
cdalten@gmail.com: Mar 04 06:02AM -0800 On Tuesday, March 3, 2020 at 7:26:55 AM UTC-8, Frederick Gotham wrote: > result += buffer.data(); > } > return result; Ugh...does every other person feel the need to use this idiotic construct? By that way, this can cause undefined behavior. And with, I'm adding the next person to my killfile who thinks this construct is okay and then tries to justify it with some lame, divorced from reality excuse. |
cdalten@gmail.com: Mar 04 06:04AM -0800 On Wednesday, March 4, 2020 at 12:39:56 AM UTC-8, Maciej Sobczak wrote: > It might be negligible in your particular case (the result might have some integrity features built in its syntax), but is worth being aware of before copy-pasting this code to some other arbitrary system. > But it's true, custom deleters in smart pointers are indeed powerful. :-) > -- And the code can also produce undefined behavior. More to the point, I can think of a case where this idiot construct would evaluate to true when the expression is actually false. |
cdalten@gmail.com: Mar 04 06:16AM -0800 > > But it's true, custom deleters in smart pointers are indeed powerful. :-) > > -- > And the code can also produce undefined behavior. More to the point, I can think of a case where this idiot construct would evaluate to true when the expression is actually false. The ultimate moral is, don't copy and paste things from Stackoverflow unless you know the person's credentials. Because in this case, the person on Stackoverflow who posted this code needs to stay as a Junior Software Developer or the tech support person. |
"Öö Tiib" <ootiib@hot.ee>: Mar 04 08:25AM -0800 > > return result; > Ugh...does every other person feel the need to use this idiotic construct? By that way, this can cause undefined behavior. > And with, I'm adding the next person to my killfile who thinks this construct is okay and then tries to justify it with some lame, divorced from reality excuse. What kind of undefined behavior? What construct? Usage of unique_ptr for simple RAII cleanup is well-known idiom. No point to make full-blown wrapper on every case. Launcing sub-processes or opening external communication channels should not be taken that lightly however. Such std::unique_ptr<FILE, std::function<void(FILE*)>> feels too naive there. |
cdalten@gmail.com: Mar 04 09:01AM -0800 On Wednesday, March 4, 2020 at 8:25:14 AM UTC-8, Öö Tiib wrote: > channels should not be taken that lightly however. Such > std::unique_ptr<FILE, std::function<void(FILE*)>> feels too > naive there. This line... while ( nullptr != fgets(buffer.data(), buffer.size(), pipe.get()) ) If nullptr returns a value, the entire expression nullptr != fgets(buffer.data(), buffer.size(), pipe.get()) could get evaluated. Whereas if nullptr was was on the other side, it will throw a runtime error(?). I think that's how it's worded. The only reason I know this is because I've dealt with a class of bugs similar to this. And it *always* stems from "inverting" the expression. |
"Öö Tiib" <ootiib@hot.ee>: Mar 04 10:00AM -0800 > If nullptr returns a value, the entire expression > nullptr != fgets(buffer.data(), buffer.size(), pipe.get()) > could get evaluated. Uh, I don't follow. The nullptr is a keyword of C++ that can be used as null pointer constant expression. It was added to make sure that it can't be implicitly converted to or compared with integer constant (the issue that NULL had). The fgets is documented to return null pointer when there was end of file before reading any characters or error occurred during reading. So the line is technically just more explicit way to write: while ( fgets(buffer.data(), buffer.size(), pipe.get()) ) > Whereas if nullptr was was on the other side, it will throw a runtime error(?). I think that's how it's worded. The only reason I know this is because I've dealt with a class of bugs similar to this. And it *always* stems from "inverting" the expression. How it can throw? The fgets is C library function so noexcept and inbuilt operator != between two pointers is also noexcept. User has to call ferror(pipe.get()) to find out if there was error or not, nothing should throw there. |
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