Thread: Warnings in FILE input code

  1. #1
    Anirban Ghosh
    Join Date
    Jan 2006
    Posts
    278

    Warnings in FILE input code

    Code:
    #include <iostream>
    #include <fstream>
    #include <list>
    
    using namespace std;
    
    int main()
    {
        int no_of_vertices;
        ifstream fin;
    
        fin.open("RECTANGLE_GRAPH.txt",ios::in);
    
        if( !fin )
        {
            cout << "File not found!" << endl;
            return 1;
        }
    
        fin >> no_of_vertices;
    
        return 0;
    }
    Code:
    /usr/include/c++/4.4/fstream||In constructor ‘std::basic_ifstream<_CharT, _Traits>::basic_ifstream() [with _CharT = char, _Traits = std::char_traits<char>]’:|
    /usr/include/c++/4.4/fstream|440|warning: will never be executed|
    /usr/include/c++/4.4/fstream|440|warning: will never be executed|
    /usr/include/c++/4.4/fstream|440|warning: will never be executed|
    /usr/include/c++/4.4/fstream|440|warning: will never be executed|
    /usr/include/c++/4.4/fstream|441|warning: will never be executed|
    /usr/include/c++/4.4/fstream|441|warning: will never be executed|
    /usr/include/c++/4.4/bits/basic_ios.h||In constructor ‘std::basic_ios<_CharT, _Traits>::basic_ios() [with _CharT = char, _Traits = std::char_traits<char>]’:|
    /usr/include/c++/4.4/bits/basic_ios.h|453|warning: will never be executed|
    /usr/include/c++/4.4/istream||In constructor ‘std::basic_istream<_CharT, _Traits>::basic_istream() [with _CharT = char, _Traits = std::char_traits<char>]’:|
    /usr/include/c++/4.4/istream|582|warning: will never be executed|
    /usr/include/c++/4.4/istream|582|warning: will never be executed|
    /usr/include/c++/4.4/istream|582|warning: will never be executed|
    /usr/include/c++/4.4/istream|582|warning: will never be executed|
    /usr/include/c++/4.4/istream|583|warning: will never be executed|
    /usr/include/c++/4.4/istream|583|warning: will never be executed|
    /usr/include/c++/4.4/istream||In destructor ‘std::basic_istream<_CharT, _Traits>::~basic_istream() [with _CharT = char, _Traits = std::char_traits<char>]’:|
    /usr/include/c++/4.4/istream|102|warning: will never be executed|
    /usr/include/c++/4.4/istream|102|warning: will never be executed|
    /usr/include/c++/4.4/istream|102|warning: will never be executed|
    /usr/include/c++/4.4/fstream||In destructor ‘std::basic_ifstream<_CharT, _Traits>::~basic_ifstream() [with _CharT = char, _Traits = std::char_traits<char>]’:|
    /usr/include/c++/4.4/fstream|486|warning: will never be executed|
    /usr/include/c++/4.4/fstream|486|warning: will never be executed|
    /usr/include/c++/4.4/fstream|486|warning: will never be executed|
    /usr/include/c++/4.4/fstream|486|warning: will never be executed|
    /usr/include/c++/4.4/fstream|486|warning: will never be executed|
    ||=== Build finished: 0 errors, 21 warnings ===|
    Using CODE BLOCKS 10.05 in UBUNTU 10.10. Any help please?

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    The problem is in your installation of the standard library (which is typically installed with your compiler).

    You might want to report the warnings to the supplier of your compiler. My guess - although I don't know - is that your compiler is part of the bundle delivered by default with Ubuntu, although that won't be true if you installed a separate package. So, it would be appropriate to report the concern to the Ubuntu folks in the first instance.

    For your work, you can ignore the warnings. "never be executed" simply means some functions contain some additional code, but - because of the logic of those function - there is no way that extra code will be executed.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. opening empty file causes access violation
    By trevordunstan in forum C Programming
    Replies: 10
    Last Post: 10-21-2008, 11:19 PM
  2. Trouble with a lab
    By michael- in forum C Programming
    Replies: 18
    Last Post: 12-06-2005, 11:28 PM
  3. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM