- Functions and the linker - 10 Updates
- OT: Association for Orthodox Jewish Scientists - 7 Updates
- Get and set file/folder ACLs using c/c++ - 3 Updates
- Inheritance-type enum - 1 Update
- C++ exceptions are broken. - 2 Updates
- C - 1 Update
- didactics of reference parameters[Supersedes] - 1 Update
Alain Ketterlin <alain@universite-de-strasbourg.fr.invalid>: Mar 17 10:49AM +0100 > expression is odr-used if it is the unique lookup result or the selected > member of a set of overloaded functions (3.4, 13.3, 13.4), unless it is > a pure virtual function and its name is not explicitly qualified." The question now is: is the name "potentially evaluated" in the example? > Seems pretty straight-forward to me that this means that using the > name of a function as a void* argument to operator<< is an odr-use of > the name. void * is irrelevant here, there is no implicit conversion between a function-pointer to void *. The only applicable conversion is to bool, which is what happens here. Since the conversion to bool is "implicit" (4.12), it is not clear to me whether the name is "potentially-evaluated". (5.20) says that "an lvalue-to-rvalue conversion" is a constant expression, therefore, not potentially-evaluated (3.2). If this applies here, then the function name is not odr-used, and gcc is correct. But beyond that, I have to say that I'm lost in the standard's vocabulary. So I disagree with you that the conclusion is "straight-forward". -- Alain. |
Paavo Helde <myfirstname@osa.pri.ee>: Mar 17 02:26PM +0200 On 17.03.2016 11:49, Alain Ketterlin wrote: > lvalue-to-rvalue conversion" is a constant expression, therefore, not > potentially-evaluated (3.2). If this applies here, then the function > name is not odr-used, and gcc is correct. gcc is correct anyway because "no diagnostic required" and UB includes a program working as expected. The question is if the program has UB and if not, then MSVC is not correct when rejecting the program. > But beyond that, I have to say that I'm lost in the standard's > vocabulary. So I disagree with you that the conclusion is > "straight-forward". Agreed. |
legalize+jeeves@mail.xmission.com (Richard): Mar 17 04:44PM [Please do not mail me a copy of your followup] Alain Ketterlin <alain@universite-de-strasbourg.fr.invalid> spake the secret code >> member of a set of overloaded functions (3.4, 13.3, 13.4), unless it is >> a pure virtual function and its name is not explicitly qualified." >The question now is: is the name "potentially evaluated" in the example? It is not only potentially evaluated it is actually evaluated. 2. "An expression is /potentially evaluated/ unless it is an unevaluated operand (Clause 5) or a subexpression thereof." This is an evaluated operand to operator<<, so it is potentially evaluated. >void * is irrelevant here, there is no implicit conversion between a >function-pointer to void *. The only applicable conversion is to bool, >which is what happens here. OK fine, whatever, I picked the wrong overload of operator<< for a stream with a pointer to function. It doesn't change anything here. >lvalue-to-rvalue conversion" is a constant expression, therefore, not >potentially-evaluated (3.2). If this applies here, then the function >name is not odr-used, and gcc is correct. I'm looking at C++14 draft standard, which has no section 5.20. -- "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 04:45PM [Please do not mail me a copy of your followup] Paavo Helde <myfirstname@osa.pri.ee> spake the secret code >gcc is correct anyway because "no diagnostic required" and UB includes a >program working as expected. I don't see any undefined behavior here. What I see is an odr-use of a name that isn't defined. Please show me how I got it wrong and convince me :-). I will learn more that way. -- "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> |
red floyd <no.spam@its.invalid>: Mar 17 09:48AM -0700 On 3/16/2016 3:44 PM, Stefan Ram wrote: > using namespace ::std::literals; > ::std::string s() {} /* this line was added 2016-03-16 */ > int main() { ::std::string const s(); ::std::cout << '>' << s << "<\n"s; } Still shouldn't compile. s() does not return a value. |
Alain Ketterlin <alain@universite-de-strasbourg.fr.invalid>: Mar 17 06:05PM +0100 > operand (Clause 5) or a subexpression thereof." > This is an evaluated operand to operator<<, so it is potentially > evaluated. No, it is an operand to the implicit conversion to bool, which doesn't require evaluation, as I understand it. >>potentially-evaluated (3.2). If this applies here, then the function >>name is not odr-used, and gcc is correct. > I'm looking at C++14 draft standard, which has no section 5.20. I'm looking at "Working Draft, Standard for Programming Language C ++", 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. -- Alain. |
Paavo Helde <myfirstname@osa.pri.ee>: Mar 17 08:16PM +0200 On 17.03.2016 11:49, Alain Ketterlin wrote: > whether the name is "potentially-evaluated". (5.20) says that "an > lvalue-to-rvalue conversion" is a constant expression, therefore, not > potentially-evaluated (3.2). If this reasoning is correct, then I feel also the following should compile: #include <iostream> #include <string> std::string const s(); constexpr std::string const (*s2)() = s; int main() { std::cout << '>' << s2 << "<\n"; } Alas, this fails with gcc: >g++ -std=c++11 main.cpp /tmp/ccUI16zy.o:main.cpp:(.rdata+0x8): undefined reference to `s()' collect2: error: ld returned 1 exit status |
Paavo Helde <myfirstname@osa.pri.ee>: Mar 17 08:30PM +0200 On 17.03.2016 18:45, Richard wrote: >> program working as expected. > I don't see any undefined behavior here. What I see is an odr-use of > a name that isn't defined. 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 (because a "shall" statement in the standard is not fulfilled). Anything which is not defined by the standard is undefined. The standard only defines programs which contain exactly one definition of a 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. Cheers Paavo |
Victor Bazarov <v.bazarov@comcast.invalid>: Mar 17 02:36PM -0400 On 3/17/2016 12:48 PM, red floyd wrote: >> int main() { ::std::string const s(); ::std::cout << '>' << s << >> "<\n"s; } > Still shouldn't compile. s() does not return a value. Why? It's not a compilation failure. It can compile fine (and even run fine) if, e.g., the value-returning function without a 'return' statement is never actually called. V -- I do not respond to top-posted replies, please don't ask |
Alain Ketterlin <alain@universite-de-strasbourg.fr.invalid>: Mar 17 09:18PM +0100 Paavo Helde <myfirstname@osa.pri.ee> writes: [...] >>g++ -std=c++11 main.cpp > /tmp/ccUI16zy.o:main.cpp:(.rdata+0x8): undefined reference to `s()' > collect2: error: ld returned 1 exit status Well, this is expected: the value of s is now used in a conversion to a function pointer. The same would happen if you cast s to void* to call operator<<(void*) on cout. But if you replace your s2 with: bool s2 = s; then it compiles & links. The strange behavior is due to the conversion to bool. -- Alain. |
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Mar 17 12:39AM > or Is Technology Using Us?" > ----------------------------------------------------------- > This is great news. Is cuntflaps a word? I think it is. https://www.youtube.com/watch?v=V7kTYyOMylQ /Flibble |
woodbrian77@gmail.com: Mar 16 06:18PM -0700 On Wednesday, March 16, 2016 at 7:39:57 PM UTC-5, Mr Flibble wrote: Leigh, vulgarity isn't helpful. |
Gareth Owen <gwowen@gmail.com>: Mar 17 06:57AM > On Wednesday, March 16, 2016 at 7:39:57 PM UTC-5, Mr Flibble wrote: > Leigh, vulgarity isn't helpful. Neithers proselytising so we'll call it a draw. (Leigh wins the tie-break, based on brevity). |
Juha Nieminen <nospam@thanks.invalid>: Mar 17 10:45AM > Leigh, vulgarity isn't helpful. I know that you have this belief that pretty much amounts to your words having magic behind them, because you think that when you preach, your god will supernaturally start affecting people's minds and maybe convert them to your religion. (You of course shove aside the question of why your god is so weak that he needs and intermediate like you to preach his word to people, but that's besides the point.) But you should just accept reality. Your words are not magical. Your "god" will not bestow them with magical power. Your "god" will not have any more or less effect on people depending on how many preaching word you spout to them. Your "god" will not start influencing people just because you preached to them. The only thing you are achieving with your proselytizing is to make yourself sound pushy and insufferable. But of course that's what you 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. Just stop it, and start acting like a normal likeable human being. You can believe whatever you want, but when you start pushing those beliefs onto others, you are only going to gain antipathy. And this self-victimization will only give you pleasure for so long; in the long run it won't be worth it. You will only get depressed and isolated. For your own sake, just start acting like a normal reasonable human being. --- news://freenews.netfront.net/ - complaints: news@netfront.net --- |
legalize+jeeves@mail.xmission.com (Richard): Mar 17 04:50PM [Please do not mail me a copy of your followup] woodbrian77@gmail.com spake the secret code >[completely unrelated to C++ posting] You see, this is why religious nutjobs like you are not respected. (Note: I am calling him a "religious nutjob" as a noun phrase and not saying that all religious people are notjubs. I don't object to religious people, but I object to religious nutjobs.) You've got that stick so far up your ass that you just can't control yourself and stick to the topic of this newsgroup. You just *have* to abuse everything within your grasp in order to beat people over the head with your unsolicited message. Take it to a religious newsgroup where it is within the charter. If you're going to post to comp.lang.c++ then do what Jesus would do (since you hold him as your example to follow) and stick to the topic. -- "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> |
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Mar 17 06:08PM > On Wednesday, March 16, 2016 at 7:39:57 PM UTC-5, Mr Flibble wrote: > Leigh, vulgarity isn't helpful. God has cuntflaps doesn't she Brian? /Flibble |
Cholo Lennon <chololennon@hotmail.com>: Mar 17 03:18PM -0300 On 03/17/2016 07:45 AM, Juha Nieminen wrote: > long run it won't be worth it. You will only get depressed and isolated. > For your own sake, just start acting like a normal reasonable human > being. +1 I wouldn't have it written better. -- Cholo Lennon Bs.As. ARG |
Zeljko Radicevic <zeljko.radicevic@gmail.com>: Mar 17 10:03AM +0100 Hello everybody What is easiest way to get file/folder ACLs on Linux system using C/C++ programming languange? I'm looking for some simple example Thank you Zeljko |
Jerry Stuckle <jstucklex@attglobal.net>: Mar 17 10:07AM -0400 On 3/17/2016 5:03 AM, Zeljko Radicevic wrote: > I'm looking for some simple example > Thank you > Zeljko http://bfy.tw/4ngc -- ================== Remove the "x" from my email address Jerry Stuckle jstucklex@attglobal.net ================== |
red floyd <no.spam@its.invalid>: Mar 17 09:50AM -0700 On 3/17/2016 2:03 AM, Zeljko Radicevic wrote: > What is easiest way to get file/folder ACLs on Linux system using C/C++ > programming languange? > I'm looking for some simple example 1. There is no such language as C/C++. There is C, and there is C++. 2. The ISO standard for C++ does not mention "file/folder ACLs". What you are looking for is a newsgroup with either "linux" or "unix" in its name. |
JiiPee <no@notvalid.com>: Mar 17 02:10PM On 16/03/2016 19:47, Alf P. Steinbach wrote: >> that when adding a new class I do not need to touch the original enum >> definition but I can add the type inside the new class. > Instead of these integer identifiers you can probably use typeid. but typeid returns a type: std::type_info <http://en.cppreference.com/w/cpp/types/type_info>Which would not be user defined type, its a C++ type. later on I want to have a unique type for this: void GetAnimal(animal_type type) { ... } if I use: void GetAnimal(std::type_info <http://en.cppreference.com/w/cpp/types/type_info>type) { ... } then it accepts many other types as well , other than animals type (it accepts any type_info). >> something similar to enum or class-type. > The only practical way I can see is declare the enum type centrally, > with values for all possible types. the problem i see here is that if this enum is part of the library, then we would need to recombile the library to be able to add a new animal type to this enum. We would need to modify the library to add a user defined animal. Lets say the libary contains animals (types): lion, cat, dog. then the use can add more animals , like a mouse. But if I add it to librarys enum, then the whole libarary must be recombiled. |
"Alf P. Steinbach" <alf.p.steinbach+usenet@googlemail.com>: Mar 17 06:43AM -0600 On 15.03.2016 19:22, Bo Persson wrote: > There is also a constructor > explicit logic_error(const char*); > which doesn't have to call a string constructor. Oh, it has to allocate memory dynamically for the string if it exceeds some buffer size, because there is no requirement that the actual argument points to a string that will outlive the exception object. Most probably any particular implementation delegates the dynamic allocation job to `std::string`. However, considering that `what` is virtual function that produces a `char const*`, it's not difficult at all to create a derived exception class that doesn't do dynamic allocation. Cheers!, - Alf -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] |
Paavo Helde <myfirstname@osa.pri.ee>: Mar 17 06:43AM -0600 On 15.03.2016 20:22, Bo Persson wrote: > There is also a constructor > explicit logic_error(const char*); > which doesn't have to call a string constructor. The const char* argument is not guaranteed to be a static string so it still needs to be copied over, allocating an arbitrarily large amount of memory. The standard also says: logic_error(const char* what_arg); 4 Effects: Constructs an object of class logic_error. 5 Postcondition: strcmp(what(), what_arg) == 0. The post-condition makes it illegal to ignore or truncate the argument string, thus leaving an exception as the only conforming way to cope with memory exhaustion. It is interesting to note that MSVC implementation for example appears to be not standard conforming and just ignores the argument if the memory allocation fails. -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] |
Juha Nieminen <nospam@thanks.invalid>: Mar 17 10:51AM > 1. Design an algorithm to print hello world to the screen. Can that even be called and algorithm? Do you even know what an algorithm is? --- news://freenews.netfront.net/ - complaints: news@netfront.net --- |
Juha Nieminen <nospam@thanks.invalid>: Mar 17 10:49AM > If the object is large copying it will be a performance bottleneck and if it > is really large the copy for call by value will not be possible because of > not enough memory. But the original poster didn't ask how it behaves differently. He asked what is needed to call pre-defined functions. I can't think of a single situation where calling a function taking a std::string by value would be different from calling a function taking a std::string by const reference. --- news://freenews.netfront.net/ - complaints: news@netfront.net --- |
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