www.digitalmars.com         C & C++   DMDScript  

c++.stl - Compiler complains of copy on implied return for an STL vector

reply hessrt earthlink.net writes:
Guys;

I'm attempting to work through a series of STL examples from a back issue of the
C++ report and my step 1 program looks like the following:

#include <vector>


vector<int> less_than_10(const vector<int>& vec)
{
vector<int> nvec;

for (int i = 0; i < vec.size(); ++i)
{
if (vec[i] < 10 )
{
nvec.push_back( vec[i] );
}
}

return nvec;
}

Anyway I compile and get this error:
sc trythis.c -A -cpp -Ae -Ar -r -J -mnw -C -WA -S -5 -a4 -c -l -gf
-IC:\dm\include -I c:\dm\stl -otrythis.obj 
Error: C:\DM\PROGRAMS\trythis.c(23): implied return of vector<int
,__default_alloc_template<0,0> >::_M_allocate_and_copy at closing '}' does not
return value
Lines Processed: 5046  Errors: 1  Warnings: 0
Build failed



I have to mention that this is my 1st programming attempt with Digital Mars and
yes it is an older version 7.5.3. I am including the STL library in my project
and the compiler is finding vector. If anyone has an idea of what's going on I'd
appreciate some help.

Rick
hessrt earthlink.net
Jan 06 2006
next sibling parent Arjan <arjan ask.me> writes:
hessrt earthlink.net wrote:
 Guys;
 
 I'm attempting to work through a series of STL examples from a back issue of
the
 C++ report and my step 1 program looks like the following:
 
 #include <vector>
 
 
 vector<int> less_than_10(const vector<int>& vec)
 {
 vector<int> nvec;
 
 for (int i = 0; i < vec.size(); ++i)
 {
 if (vec[i] < 10 )
 {
 nvec.push_back( vec[i] );
 }
 }
 
 return nvec;
 }
 
 Anyway I compile and get this error:
 sc trythis.c -A -cpp -Ae -Ar -r -J -mnw -C -WA -S -5 -a4 -c -l -gf
 -IC:\dm\include -I c:\dm\stl -otrythis.obj 
 Error: C:\DM\PROGRAMS\trythis.c(23): implied return of vector<int
 ,__default_alloc_template<0,0> >::_M_allocate_and_copy at closing '}' does not
 return value
 Lines Processed: 5046  Errors: 1  Warnings: 0
 Build failed
 
 
 
 I have to mention that this is my 1st programming attempt with Digital Mars and
 yes it is an older version 7.5.3. I am including the STL library in my project
 and the compiler is finding vector. If anyone has an idea of what's going on
I'd
 appreciate some help.

Upgrade your compiler to a more recent version with better ansi/iso c++ template and stl support. It is really easy to do.
 
 Rick
 hessrt earthlink.net

Jan 07 2006
prev sibling next sibling parent "Matthew" <matthew stlsoft.com> writes:
Your environment and/or SC.INI is including the old HP headers, and not
STLport, which is all that DMC++ is supported with.

<hessrt earthlink.net> wrote in message
news:dpmg3l$1jsv$1 digitaldaemon.com...
 Guys;

 I'm attempting to work through a series of STL examples from a back issue
 of the
 C++ report and my step 1 program looks like the following:

 #include <vector>


 vector<int> less_than_10(const vector<int>& vec)
 {
 vector<int> nvec;

 for (int i = 0; i < vec.size(); ++i)
 {
 if (vec[i] < 10 )
 {
 nvec.push_back( vec[i] );
 }
 }

 return nvec;
 }

 Anyway I compile and get this error:
 sc trythis.c -A -cpp -Ae -Ar -r -J -mnw -C -WA -S -5 -a4 -c -l -gf
 -IC:\dm\include -I c:\dm\stl -otrythis.obj
 Error: C:\DM\PROGRAMS\trythis.c(23): implied return of vector<int
 ,__default_alloc_template<0,0> >::_M_allocate_and_copy at closing '}' does
 not
 return value
 Lines Processed: 5046  Errors: 1  Warnings: 0
 Build failed



 I have to mention that this is my 1st programming attempt with Digital
 Mars and
 yes it is an older version 7.5.3. I am including the STL library in my
 project
 and the compiler is finding vector. If anyone has an idea of what's going
 on I'd
 appreciate some help.

 Rick
 hessrt earthlink.net

Jan 07 2006
prev sibling parent reply "Walter Bright" <newshound digitalmars.com> writes:
<hessrt earthlink.net> wrote in message 
news:dpmg3l$1jsv$1 digitaldaemon.com...
 Anyway I compile and get this error:
 sc trythis.c -A -cpp -Ae -Ar -r -J -mnw -C -WA -S -5 -a4 -c -l -gf
 -IC:\dm\include -I c:\dm\stl -otrythis.obj

Use -I\dm\stlport\stlport instead of \dm\stl
Jan 08 2006
next sibling parent Rick Hess <Rick_member pathlink.com> writes:
Thnks guys for the assist. I used the "-I\dm\stlport\stlport" and it worked
great.


In article <dprqel$1h80$1 digitaldaemon.com>, Walter Bright says...
<hessrt earthlink.net> wrote in message 
news:dpmg3l$1jsv$1 digitaldaemon.com...
 Anyway I compile and get this error:
 sc trythis.c -A -cpp -Ae -Ar -r -J -mnw -C -WA -S -5 -a4 -c -l -gf
 -IC:\dm\include -I c:\dm\stl -otrythis.obj

Use -I\dm\stlport\stlport instead of \dm\stl

Jan 08 2006
prev sibling parent Rick Hess <Rick_member pathlink.com> writes:
Thanks Guys: The include of \dm\stlport\stlport worked great. 


In article <dprqel$1h80$1 digitaldaemon.com>, Walter Bright says...
<hessrt earthlink.net> wrote in message 
news:dpmg3l$1jsv$1 digitaldaemon.com...
 Anyway I compile and get this error:
 sc trythis.c -A -cpp -Ae -Ar -r -J -mnw -C -WA -S -5 -a4 -c -l -gf
 -IC:\dm\include -I c:\dm\stl -otrythis.obj

Use -I\dm\stlport\stlport instead of \dm\stl

Rick Hess
Jan 08 2006