473,396 Members | 1,871 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.

Error Message Missing

Yesterday I found that an invocation of a member function that
lacked the required "()" pararenthesis did not generate an error
message. This was an invocation of a member function that is part
of a library so I do not have access to the source code. The
compiler was MSVC++ 6.0.

I can't think of any scenario that would prevent a compiler error
message from being generated. Can some one please explain
how this could have occurred?
Jul 22 '05 #1
4 1511
Peter Olcott wrote:
Yesterday I found that an invocation of a member function that
lacked the required "()" pararenthesis did not generate an error
message. This was an invocation of a member function that is part
of a library so I do not have access to the source code. The
compiler was MSVC++ 6.0.
You mean something like below?

| struct foo
| {
| void bar() {}
| };
|
| int main()
| {
| foo f;
| f.bar; // <--- note this line!
| }

I guess you have something like the highlighted line: well,
this is effectively a valid expression which determines a
pointer-to-member-function and discards it unused. The
compiler on the system I'm currently using issues this
message:

| "tst.cpp", line 9: Warning: The value of <expression>.foo::bar
| is unused.

(plus a warning about the uninitialized 'f' but this is
irrelevant to this discussion).

It is possible to make the warning go away by actually using
the value, e.g. by assigning it to a pointer-to-member-function:

| void (foo::*ptmf)() = f.bar;
I can't think of any scenario that would prevent a compiler error
message from being generated. Can some one please explain
how this could have occurred?


I'd guess that the discussion above gives an indication why
the compiler did not issue an error. It might have issued a
warning, though. It is quite similar to a problem I
encountered recently where are program caused real damage
because it executed code it should not have executed under
the given conditions. It turned out that the code was
protected by something like this:

| if (some_condition)
| std::exit;

It's nice to mention the function 'std::exit()'. It would have
been nicer to actually execute it by tagging on parenthesis.
--
<mailto:di***********@yahoo.com> <http://www.dietmar-kuehl.de/>
<http://www.contendix.com> - Software Development & Consulting

Jul 22 '05 #2

Dietmar Kuehl wrote:
Peter Olcott wrote:
Yesterday I found that an invocation of a member function that
lacked the required "()" pararenthesis did not generate an error
message. This was an invocation of a member function that is part
of a library so I do not have access to the source code. The
compiler was MSVC++ 6.0.
You mean something like below?

| struct foo
| {
| void bar() {}
| };
|
| int main()
| {
| foo f;
| f.bar; // <--- note this line!
| }

I guess you have something like the highlighted line: well,
this is effectively a valid expression which determines a
pointer-to-member-function and discards it unused.


No, it isn't. 5.3.1/3
"A pointer to member is only formed when an explicit & is used
and its operand is a qualified-id not enclosed in parentheses."

I don't understand how the poster knows the () is lacking when
he doesn't have the source code! You can't see it in a decompiled
binary.
| void (foo::*ptmf)() = f.bar;
Extension, should be a warning.
It is quite similar to a problem I
encountered recently where are program caused real damage
because it executed code it should not have executed under
the given conditions. It turned out that the code was
protected by something like this:

| if (some_condition)
| std::exit;

It's nice to mention the function 'std::exit()'. It would have
been nicer to actually execute it by tagging on parenthesis.


Not a member function, so this effectively is a (converts to)
pointer-to-plain-function. See 4.3

Regards,
Michiel Salters

Jul 22 '05 #3
msalters wrote:
I don't understand how the poster knows the () is lacking when
he doesn't have the source code!


He doesn't have the source code of the function, but that doesn't mean that
he also doesn't have the source code of the call. However, I don't see how
the source of the function could be relevant.

Jul 22 '05 #4
Here is the actual code that erroneously
produces no errors on MSVC++ 6.0

class C {
public:
void length();
void length (int);
};
void C::length() {
}
void C::length(int f) {
}
int main() {
C myC;
return myC.length;
}

"Dietmar Kuehl" <di***********@yahoo.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Peter Olcott wrote:
Yesterday I found that an invocation of a member function that
lacked the required "()" pararenthesis did not generate an error
message. This was an invocation of a member function that is part
of a library so I do not have access to the source code. The
compiler was MSVC++ 6.0.


You mean something like below?

| struct foo
| {
| void bar() {}
| };
|
| int main()
| {
| foo f;
| f.bar; // <--- note this line!
| }

I guess you have something like the highlighted line: well,
this is effectively a valid expression which determines a
pointer-to-member-function and discards it unused. The
compiler on the system I'm currently using issues this
message:

| "tst.cpp", line 9: Warning: The value of <expression>.foo::bar
| is unused.

(plus a warning about the uninitialized 'f' but this is
irrelevant to this discussion).

It is possible to make the warning go away by actually using
the value, e.g. by assigning it to a pointer-to-member-function:

| void (foo::*ptmf)() = f.bar;
I can't think of any scenario that would prevent a compiler error
message from being generated. Can some one please explain
how this could have occurred?


I'd guess that the discussion above gives an indication why
the compiler did not issue an error. It might have issued a
warning, though. It is quite similar to a problem I
encountered recently where are program caused real damage
because it executed code it should not have executed under
the given conditions. It turned out that the code was
protected by something like this:

| if (some_condition)
| std::exit;

It's nice to mention the function 'std::exit()'. It would have
been nicer to actually execute it by tagging on parenthesis.
--
<mailto:di***********@yahoo.com> <http://www.dietmar-kuehl.de/>
<http://www.contendix.com> - Software Development & Consulting

Jul 22 '05 #5

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

Similar topics

3
by: Andrew Luke | last post by:
Hi all you C++ guru's! I'm 'very, very' new to C++ and I'm having a little trouble configuring my VS environment I think - when I try and compile some sample code I'm getting the following...
0
by: Mark | last post by:
When the following VB code is executed (code from an aspx page), the following error message is issued: "Microsoft Access can't open the database because it is missing, or opened exclusively by...
102
by: Skybuck Flying | last post by:
Sometime ago on the comp.lang.c, I saw a teacher's post asking why C compilers produce so many error messages as soon as a closing bracket is missing. The response was simply because the compiler...
8
by: sudha | last post by:
Hi, To open a word doc from c#, i use the following code : Word.ApplicationClass WordApp = new Word.ApplicationClass (); // give any file name of your choice. object fileName =...
2
by: Qiao Yun | last post by:
I used vc++.net (visual studio .net ) to open a project which can work well in vc++6.0. I succeeded in compiling the project in vc++.net in release mode . But when I tried to compile the project...
0
by: Shashikiran Prabhakar via .NET 247 | last post by:
(Type your message here) Hi, I am not very conversent in VC++, but the requirement for me is to run a rendering code. However i am encountering the following errors. c:\Program...
1
by: Meken | last post by:
Hello! I have developed a function which create a word doc. It works fine for smaller amount of text but when I want to create larger documents something goes wrong! The application stops at...
1
by: Mark | last post by:
When the following VB code is executed (code from an aspx page), the following error message is issued: "Microsoft Access can't open the database because it is missing, or opened exclusively by...
7
by: John Øllgård Jensen | last post by:
Hi Using MS Asccess 2000: In a query I'm trying to create a new field with following expression: FilmDate: Left(,4) The field "FilmNo" is another text field in the query. This is...
1
by: Simon | last post by:
Dear reader, Some times I receive an error message by using the functions: Left(;2) Mid(;5;2)
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.