473,398 Members | 2,088 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

compilation warning

Hello,

I am getting complation warning saying,
warning : returning reference to temporary.

The code from which it is coming:
vector<boola_oObj;
This vector is filled with all boolean values
Then when I want to check a condition on this
for loop
int i = 0;
if(obj[i] == true) //warning comes here

Thanks in Advance,

Subrat
Jul 25 '08 #1
5 1540
Subrat wrote:
Hello,

I am getting complation warning saying,
warning : returning reference to temporary.

The code from which it is coming:
vector<boola_oObj;
This vector is filled with all boolean values
Then when I want to check a condition on this
for loop
int i = 0;
if(obj[i] == true) //warning comes here

Thanks in Advance,

Subrat

Your example doesn't compile and I do not see a return statement,
therefore can't say anything.

Next function would produce that warning:

bool& f()
{
bool a = true;
return a;
}
Jul 25 '08 #2
The example is not a perfect piece of code. Thats an abstract code

"anon" <an**@no.nowrote in message news:g6**********@news01.versatel.de...
Subrat wrote:
Hello,

I am getting complation warning saying,
warning : returning reference to temporary.

The code from which it is coming:
vector<boola_oObj;
This vector is filled with all boolean values
Then when I want to check a condition on this
for loop
int i = 0;
if(obj[i] == true) //warning comes here

Thanks in Advance,

Subrat

Your example doesn't compile and I do not see a return statement,
therefore can't say anything.

Next function would produce that warning:

bool& f()
{
bool a = true;
return a;
}

Jul 25 '08 #3
On Jul 25, 3:38 pm, "Subrat" <subrat.sah...@in.bosch.comwrote:
"anon" <a...@no.nowrote in messagenews:g6**********@news01.versatel.de...
Subrat wrote:
Hello,
I am getting complation warning saying,
warning : returning reference to temporary.
The code from which it is coming:
vector<boola_oObj;
This vector is filled with all boolean values
Then when I want to check a condition on this
for loop
int i = 0;
if(obj[i] == true) //warning comes here
Thanks in Advance,
Subrat
Your example doesn't compile and I do not see a return statement,
therefore can't say anything.

The example is not a perfect piece of code. Thats an abstract code
It's not sufficient to explain the compiler warning. I suggest you
post your actual code.

Tony
Jul 25 '08 #4
"Subrat" <su***********@in.bosch.comwrites:
Hello,

I am getting complation warning saying,
warning : returning reference to temporary.

The code from which it is coming:
vector<boola_oObj;
This vector is filled with all boolean values
Then when I want to check a condition on this
for loop
int i = 0;
if(obj[i] == true) //warning comes here
Other have mentionned that this is no compilable code. But in any
case, you show us a variable named a_oObj, and then you refer a
variable named obj.

--
__Pascal Bourguignon__
Jul 25 '08 #5
On Jul 25, 3:11*pm, "Subrat" <subrat.sah...@in.bosch.comwrote:
Hello,

I am getting complation warning saying,
warning : returning reference to temporary.

The code from which it is coming:
vector<boola_oObj;
This vector is filled with all boolean values
Then when I want to check a condition on this
for loop
int i = 0;
if(obj[i] == true) //warning comes here

Thanks in Advance,

Subrat
Please post the code of the function in which you get the warning.
You must be doing what anon said, which is,

vector<bool>& myFunc() // note the "&", if you remove that, its a
quick-fix that will work, although its one damn slow copy-constructor
{
...
vector<boolv;
return v; // warning; accessing the returned value should either
crash or read garbage
}

Cheers!
-- raicuandi
Jul 28 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Ced | last post by:
Hi, i'm not an expert in C but i try to compile BTNG software under linux kernel 2.4.2-2. I get these errors at the very first stage. Does someone could have a rapid look on this and tell me...
10
by: Rick Anderson | last post by:
All, I am receiving the following compilation error on LINUX (but not Solaris, HPUX, WIN32, etc): compiling osr.c LBFO.h(369): warning #64: declaration does not declare anything extern...
7
by: ChrisB | last post by:
Hello: I notice that the following statements generate a "the variable 'e' is declared but never used" warning: try { Company.Fetch(CompanyID); } catch(RecordNotFoundException e)
3
by: Dan | last post by:
Hi, I have a problem using an aspx page with a Control on it. I get the following error message Compiler Error Message: CS1595: 'Test.Class2' is defined in multiple places; using definition...
6
by: alban | last post by:
Hello I have got some problems of compilation on a AIX IBM, I use the XLC compilator (And I can't install another one). I try to compile code Pro*c ".pc" (oracle), I need do a pre-compilation...
6
by: subramanian | last post by:
Consider the following program: #include <stdio.h> void myfn(const int **a) { static int i, j, k; a = &i; a = &j;
1
by: hamardk | last post by:
Hi, I'm trying to compile log4cpp-0.3.5rc3 on : SunOS belaurora 5.9 Generic_118558-11 sun4u sparc SUNW,Ultra-4 I'm having compilation issues which are: In file included from...
7
by: antoine | last post by:
Hi all! I'm a French student currently doing an internship in Beijing. I have to simulate a mips machine running with the micro kernel l4. When i compile the kernel i got some compilation errors. I...
3
by: Richard Weeks | last post by:
My question, stated as simply as possible, is: must a constraint violation, as defined by the standard, cause compilation to halt? I believe that in the presence of a constraint violation, at...
4
by: | last post by:
Hi, After installing SP1 for VS2008 and SP1 for .NET 3.5 we get the following warning in a VS2005 build: error CS0618: Warning as Error: 'System.Windows.UIElement.BitmapEffect' is obsolete:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.