Bug 39730 - incomplete type error can be misleading
Summary: incomplete type error can be misleading
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.5.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2009-04-10 20:23 UTC by Ian Lance Taylor
Modified: 2023-06-08 10:01 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2014-04-04 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ian Lance Taylor 2009-04-10 20:23:41 UTC
For this example:

# include <istream>
# include <istream>

using namespace std;

ifstream  x;
ifstream  y();

int main(int argc, char** argv) {
  return 0;
}

current mainline g++ says:

foo.cc:6: error: aggregate ‘std::ifstream x’ has incomplete type and cannot be defined

This is accurate but confusing for the uninitiated.  How about something like

foo.cc:6: error: ‘std::ifstream’ was declared but not defined
Comment 1 Andrew Pinski 2009-04-16 18:26:06 UTC
>foo.cc:6: error: ‘std::ifstream’ was declared but not defined

This is even more confusing to me.  As incomplete types are understood easier than just being declared and not defined.
Comment 2 Javier Cruz 2014-04-04 21:37:51 UTC
Yo have to add the library fstream at the beginning.
Example:
#include <fstream>


That will fix the problem =)