You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by "Martin Sebor (JIRA)" <ji...@apache.org> on 2006/05/26 19:52:30 UTC
[jira] Created: (STDCXX-190) [MSVC] bogus performance warning
C4800: forcing value to bool
[MSVC] bogus performance warning C4800: forcing value to bool
-------------------------------------------------------------
Key: STDCXX-190
URL: http://issues.apache.org/jira/browse/STDCXX-190
Project: C++ Standard Library
Type: Bug
Components: External
Versions: 4.1.3
Environment: MSVC all versions up to and including 8.0
Reporter: Martin Sebor
Priority: Trivial
Copied from http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=96a52a80-a701-4402-864a-abd03917538c:
Bug ID: FDBK50482
Problem Type: Bug
Status: New
Microsoft Status: Not Reviewed
Opened Date: 2006-05-26 10:42:12
Opened By: Martin Sebor
Product/Technology: Visual C++
Version: Visual Studio 2005
Product Language: English
Category: Language/Compiler
OS: Windows 2000 Server
OS Language: US English
Submission Language: English
Description:
Opened by Martin Sebor on 2006-05-26 at 10:42:12
The warnings in the program below are bogus since the generated code is identical in all three cases.
Steps to Reproduce: $ cat -n t.cpp && cl -c -W3 -O2 -nologo -Fa t.cpp
1 bool f1 (int i)
2 {
3 return i & 2;
4 }
5
6 bool f2 (int i)
7 {
8 const bool b = i & 2;
9 return b;
10 }
11
12 bool f3 (int i)
13 {
14 const bool b = 0 != (i & 2);
15 return b;
16 }
t.cpp
t.cpp(3) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
t.cpp(8) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
Actual Results: $ cat t.asm
; Listing generated by Microsoft (R) Optimizing Compiler Version 14.00.50727.42
TITLE C:\contrib\cygwin\tmp\t.cpp
.686P
.XMM
include listing.inc
.model flat
INCLUDELIB LIBCMT
INCLUDELIB OLDNAMES
PUBLIC ?f1@@YA_NH@Z ; f1
; Function compile flags: /Ogtpy
; COMDAT ?f1@@YA_NH@Z
_TEXT SEGMENT
_i$ = 8 ; size = 4
?f1@@YA_NH@Z PROC ; f1, COMDAT
; File c:\contrib\cygwin\tmp\t.cpp
; Line 3
mov eax, DWORD PTR _i$[esp-4]
shr eax, 1
and al, 1
; Line 4
ret 0
?f1@@YA_NH@Z ENDP ; f1
_TEXT ENDS
PUBLIC ?f2@@YA_NH@Z ; f2
; Function compile flags: /Ogtpy
; COMDAT ?f2@@YA_NH@Z
_TEXT SEGMENT
_i$ = 8 ; size = 4
?f2@@YA_NH@Z PROC ; f2, COMDAT
; Line 8
mov eax, DWORD PTR _i$[esp-4]
shr eax, 1
and al, 1
; Line 10
ret 0
?f2@@YA_NH@Z ENDP ; f2
_TEXT ENDS
PUBLIC ?f3@@YA_NH@Z ; f3
; Function compile flags: /Ogtpy
; COMDAT ?f3@@YA_NH@Z
_TEXT SEGMENT
_i$ = 8 ; size = 4
?f3@@YA_NH@Z PROC ; f3, COMDAT
; Line 14
mov eax, DWORD PTR _i$[esp-4]
shr eax, 1
and al, 1
; Line 16
ret 0
?f3@@YA_NH@Z ENDP ; f3
_TEXT ENDS
END
Expected Results: No warnings.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira