Fix test-suite fallout of default -Wreturn-type.
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.other / inline8.C
blobc12a8f74a9015a0c4b66d6597917084bbf4f4705
1 // { dg-do run  }
2 // { dg-options "-O1" }
3 // Origin: Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at>
5 #include <map>
6 #include <cstdlib>
7 #include <cstring>
9 using namespace std;
11 class NAMES_ITEM
12     {
13 public:
14     char *name;
16       NAMES_ITEM(const NAMES_ITEM& item2);
18       NAMES_ITEM(const char* name2);
20       ~NAMES_ITEM();
22       bool operator==(const NAMES_ITEM& n) const;
23     };
26 NAMES_ITEM::NAMES_ITEM (const NAMES_ITEM& item2)
27         {
28         size_t length=std::strlen(item2.name);
30         name=new char[length+1];
31         std::memcpy(name,item2.name,length+1);
32         }
34 NAMES_ITEM::NAMES_ITEM (const char* name2)      
35         {
36         size_t length=std::strlen(name2);
38         name=new char[length+1];
39         std::memcpy(name,name2,length+1);
40         }
42 NAMES_ITEM::~NAMES_ITEM ()
44   if (std::strcmp (name, "one") != 0)
45     abort ();
46   
47   name=0;
50 bool NAMES_ITEM::operator==(const NAMES_ITEM& n) const
52   return (std::strcmp(name,n.name) == 0);
55 bool operator<(const NAMES_ITEM& n1, const NAMES_ITEM& n2)
56     {
57     return (std::strcmp(n1.name,n2.name) < 0);
58     }
60     typedef map<NAMES_ITEM,size_t,less<NAMES_ITEM> > lookup_t;
62     lookup_t lookup;
64         NAMES_ITEM item ("one");
66 int
67 main()
68   {
69         lookup.insert(pair<NAMES_ITEM,size_t>(item,0));
70         return 0;
71   }