c++ - Getting weird warnings
- Jim Jennings (34/34) Apr 09 2003 This program works, but what are these warnings all about? The program
- Matthew Wilson (13/47) Apr 09 2003 I've had some similar ones from STLPort. I think it's because some STLPo...
- Richard Grant (22/27) Apr 10 2003 While I can't speak for Christof, I can say that if I have serious probl...
- Jim Jennings (10/22) Apr 10 2003 Since the thread has appeared
- Walter (4/11) Apr 10 2003 -o by itself means "optimize". -ofilename means write the output to
- Jim Jennings (11/24) Apr 10 2003 I am using a makefile written for the GNU compiler, that I adapted for d...
- Walter (16/25) Apr 10 2003 dmc.
- Jim Jennings (8/22) Apr 10 2003 Since the thread has appeared
This program works, but what are these warnings all about? The program compiles on g++ and bcc32 without complaint. From STL Tutorial and Reference, Second Edition, Musser, Derge, Saini ex02-08.cpp, pp. 29-30 // Demonstrating the generic find algorithm with a deque #include <iostream> #include <cassert> #include <deque> #include <algorithm> // For find using namespace std; template <typename Container> Container make(const char s[]) { return Container(&s[0], &s[strlen(s)]); } int main() { cout << "Demonstrating generic find algorithm with " << "a deque." << endl; deque<char> deque1 = make< deque<char> >("C++ is a better C"); // Search for the first occurrence of the letter e: deque<char>::iterator where = find(deque1.begin(), deque1.end(), 'e'); assert (*where == 'e' && *(where + 1) == 't'); cout << " --- Ok." << endl; return 0; }: C:\dm\bin\sc -Ae -C -WA -S -5 -a8 -o ex02-08.exe ex02-08.cpp -I\dm\stlport\stlport ex02-08.cpp(27) : Warning 12: variable 'char ** __cur_node' used before set ex02-08.cpp(27) : Warning 12: variable 'char ** __cur' used before set ex02-08.cpp(27) : Warning 12: variable 'char ** __cur' used before set link ex02-08,ex02-08,,user32+kernel32/noi;
Apr 09 2003
I've had some similar ones from STLPort. I think it's because some STLPort functions throw as the last action within function bodies, so there's no return statement. Oh, no, sorry. That was my errors. Doesn't seem to be the explanation for yours. I'd like to put some effort into the STLPort, if no-one else is - if they are then am more than happy to leave it - but time's not going to be friendly for a while. Is there someone that has taken the STLPort under their wing? (Is that Christof?) "Jim Jennings" <jwjenn mindspring.com> wrote in message news:b72m69$1oin$1 digitaldaemon.com...This program works, but what are these warnings all about? The program compiles on g++ and bcc32 without complaint. From STL Tutorial and Reference, Second Edition, Musser, Derge, Saini ex02-08.cpp, pp. 29-30 // Demonstrating the generic find algorithm with a deque #include <iostream> #include <cassert> #include <deque> #include <algorithm> // For find using namespace std; template <typename Container> Container make(const char s[]) { return Container(&s[0], &s[strlen(s)]); } int main() { cout << "Demonstrating generic find algorithm with " << "a deque." << endl; deque<char> deque1 = make< deque<char> >("C++ is a better C"); // Search for the first occurrence of the letter e: deque<char>::iterator where = find(deque1.begin(), deque1.end(), 'e'); assert (*where == 'e' && *(where + 1) == 't'); cout << " --- Ok." << endl; return 0; }: C:\dm\bin\sc -Ae -C -WA -S -5 -a8 -o ex02-08.exe ex02-08.cpp -I\dm\stlport\stlport ex02-08.cpp(27) : Warning 12: variable 'char ** __cur_node' used beforesetex02-08.cpp(27) : Warning 12: variable 'char ** __cur' used before set ex02-08.cpp(27) : Warning 12: variable 'char ** __cur' used before set link ex02-08,ex02-08,,user32+kernel32/noi;
Apr 09 2003
In article <b72obm$1ptq$1 digitaldaemon.com>, Matthew Wilson says...I'd like to put some effort into the STLPort, if no-one else is - if they are then am more than happy to leave it - but time's not going to be friendly for a while. Is there someone that has taken the STLPort under their wing? (Is that Christof?)While I can't speak for Christof, I can say that if I have serious problems with stlport, Christof is the one I'm going to go begging to. As for the warnings, I mentioned in a much earlier thread that these were warnings that appeared whenever a release build was made using deque (and possibly a few others). I also added that they were annoying, but probably harmless since no one has tracked them down. Since the thread has appeared again, they are no longer "harmless" as they are wasting time.. so: void fn(int i) { } int main() { int i; try { } catch (...) { fn(i); } } // Warning 12: variable 'int i' used before set This is a design point made in STL for efficiency. __cur_node is assigned inside the try block, and exceptions can only be thrown after the assignment. I don't know what Walter wants to do with this. Warnings are generated for optimized builds, but not for non optimized builds. Richard
Apr 10 2003
"Richard Grant" <fractal clark.net> wrote in message news:b74gfm$2uo7$1 digitaldaemon.com...In article <b72obm$1ptq$1 digitaldaemon.com>, Matthew Wilson says...Since the thread has appearedagain, they are no longer "harmless" as they are wasting time.. so: void fn(int i) { } int main() { int i; try { } catch (...) { fn(i); } } // Warning 12: variable 'int i' used before set RichardI discovered that the warning messages are caused by the space between the -o flag and the output file name in the command line: C:\dm\bin\sc -Ae -C -WA -S -5 -a8 -o ex02-08.exe ex02-08.cpp -I\dm\stlport\stlport Take out the space and the warnings go away. I will not waste any more time of my time. Jim J.
Apr 10 2003
"Jim Jennings" <jwjenn mindspring.com> wrote in message news:b74u7v$5rk$1 digitaldaemon.com...I discovered that the warning messages are caused by the space between the -o flag and the output file name in the command line: C:\dm\bin\sc -Ae -C -WA -S -5 -a8 -o ex02-08.exe ex02-08.cpp -I\dm\stlport\stlport Take out the space and the warnings go away. I will not waste any more time of my time. Jim J.-o by itself means "optimize". -ofilename means write the output to filename.
Apr 10 2003
"Walter" <walter digitalmars.com> wrote in message news:b753dc$9bu$2 digitaldaemon.com..."Jim Jennings" <jwjenn mindspring.com> wrote in message news:b74u7v$5rk$1 digitaldaemon.com...I am using a makefile written for the GNU compiler, that I adapted for dmc. g++ has an option -o <file> "place output into file", (with space). That's the way the makefile is written, -o $ -- with a space -- and it compiles with g++. I think that -ofilename and -o optimizer flag (whatever they are) is a very fine distinction. Probably not one person in a thousand coming over from gcc would be diligent enough to catch the difference. However, all this is beside the point. Digital Mars is now relegated to file 13. Apparently everyone is happy working around the bugs and gratuitous warnings. So there is no point in posting them anymore.I discovered that the warning messages are caused by the space between the -o flag and the output file name in the command line: C:\dm\bin\sc -Ae -C -WA -S -5 -a8 -o ex02-08.exe ex02-08.cpp -I\dm\stlport\stlport Take out the space and the warnings go away. I will not waste any more time of my time. Jim J.-o by itself means "optimize". -ofilename means write the output to filename.
Apr 10 2003
"Jim Jennings" <jwjenn mindspring.com> wrote in message news:b758nl$cma$1 digitaldaemon.com...I am using a makefile written for the GNU compiler, that I adapted fordmc.g++ has an option -o <file> "place output into file", (with space). That's the way the makefile is written, -o $ -- with a space -- and it compiles with g++. I think that -ofilename and -o optimizer flag (whatever theyare)is a very fine distinction. Probably not one person in a thousand coming over from gcc would be diligent enough to catch the difference. However, all this is beside the point. Digital Mars is now relegated tofile13. Apparently everyone is happy working around the bugs and gratuitous warnings. So there is no point in posting them anymore.If I changed the way the command line worked, it would break innumerable existing makefiles. It's not really an option to do that. Every compiler has odd command line syntax in one way or another, there's no standard, it's all in what you're used to. The existing syntax was not really designed to be that way, it is an accumulation of 20 years of adding features while retaining backward compatibility. In the unix world, it's convention to put a space between a switch and its argument. In the DOS/Win32 world, the convention is to not have a space between. Neither is wrong or right, it's just convention. What I do with projects for multiple compilers is just go ahead and do a unique makefile for each compiler.
Apr 10 2003
"Richard Grant" <fractal clark.net> wrote in message news:b74gfm$2uo7$1 digitaldaemon.com...In article <b72obm$1ptq$1 digitaldaemon.com>, Matthew Wilson says...Since the thread has appearedagain, they are no longer "harmless" as they are wasting time.. so: void fn(int i) { } int main() { int i; try { } catch (...) { fn(i); } } // Warning 12: variable 'int i' used before set This is a design point made in STL for efficiency. __cur_node is assignedinsidethe try block, and exceptions can only be thrown after the assignment. RichardI am missing something here? What are you saying? That I should put a try/catch sequence in my source code to suppress a compiler warning? Or did I overlook another smiley? James
Apr 10 2003