Thread overview
Compiler complains of copy on implied return for an STL vector
Jan 06, 2006
hessrt
Jan 07, 2006
Arjan
Jan 07, 2006
Matthew
Jan 08, 2006
Walter Bright
Jan 09, 2006
Rick Hess
Jan 09, 2006
Rick Hess
January 06, 2006
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
January 07, 2006
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
January 07, 2006
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



January 08, 2006
<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


January 09, 2006
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
>
>


January 09, 2006
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