473,396 Members | 1,834 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,396 software developers and data experts.

Should this generate a warning?

I ran into a code fragment similar to the following in a production
code base - although it was even worse since the class jimlad was a
class for doing locking similar to boost::mutex::scoped_lock.

class jimlad {
public:
jimlad( int a ) { std::cout << "CONSTRUCT JIMLAD" << std::endl; }
~jimlad() { std::cout << "DESTRUCT JIMLAD" << std::endl; }
};

int main(int argc, char* argv[])
{
jimlad(1); //** This line

std::cout << "MIDDLE" << std::endl;

return 0;
}

The output is
CONSTRUCT JIMLAD
DESTRUCT JIMLAD
MIDDLE

I know that the original author intended the marked line to read
"jimlad something(1)" and to produce the output

CONSTRUCT JIMLAD
MIDDLE
DESTRUCT JIMLAd

and I can see why the code is wrong. My question is should it produce
a warning? It doesn't on VC7.1 or VC8, but I don't have any other
compilers handy to try it with, or a copy of the standard.

Can anyone try it on another compiler or let me know why it doesn't
warn you? Unused temporary or something would seem right to me.

Jun 19 '07 #1
2 1292
st*************@googlemail.com wrote:
Can anyone try it on another compiler or let me know why it doesn't
warn you? Unused temporary or something would seem right to me.
You can check any code you want against the compiler best known as the
most standard compliant around here:
http://www.comeaucomputing.com/tryitout/
Jun 19 '07 #2
On Tue, 19 Jun 2007 09:17:32 -0700 in comp.lang.c++,
st*************@googlemail.com wrote,
>Can anyone try it on another compiler or let me know why it doesn't
warn you? Unused temporary or something would seem right to me.
It is the compiler's prerogative to warn you or not warn you about
anything it might feel like (in addition to diagnostics required by the
standard.) Unused temporaries are ubiquitous, for example unused return
values from functions, and a compiler that warned you about every little
routine thing like that might not be very popular.
Jun 19 '07 #3

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

Similar topics

1
by: Prakash | last post by:
Hi, I want to generate the JDK API using Javadoc. I have installed java 1.4.2 in WINDOWS. Since i don't have frequent access to the Net, i want to generate the Java API Help using javadoc.But I...
0
by: Vijay Chegu | last post by:
Hi All, I am trying to port a perfectly working 32bit COM module developed in VC++ from 64bit. I am not able to generate .tlb file through midl compiler. I set the property thru the...
0
by: Paul | last post by:
but I am trying to generate a DBConcurrenyException to at least put up a warning message to the user if a database table record has been changed by another user before being updated by this user....
13
by: lovecreatesbeauty | last post by:
/* How do free() know how many elements should be freed in a dynamic array? When free a single variable, the amount of byte of memory can be retrieved from the type of variable itself. ...
1
by: xer | last post by:
I want to generate ssl certificate (with public key) and private key. My code: $ssl_configargs = array( "digest_alg" => "sha1", "private_key_bits" => 2048, "private_key_type" =>...
3
by: PengYu.UT | last post by:
I'm using g++. Is there any specific compiler option I can specify such that the compiler generate a warning for auto conversion from int to bool and bool to int?
2
by: yanlu06 | last post by:
I tried to use HTML2FPDF to generate dynamic local files and save the generated files on the server. I don't know why it gives me the following error message: " Warning:...
16
by: cody | last post by:
Shouldn't if (this!=null) generate a compiler warning? in fact, it does not.
82
by: robert bristow-johnson | last post by:
here is a post i put out (using Google Groups) that got dropped by google: i am using gcc as so: $ gcc -v Using built-in specs. Target: i386-redhat-linux Configured with: ../configure...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.