Re: ? Run-Time Check Failure #1 with Built-In RGB Functions
- From: "Alex Blekhman" <tkfx.REMOVE@xxxxxxxxx>
- Date: Sun, 23 Nov 2008 11:50:10 +0200
"Alec S." wrote:
Using smaller-type check option (/RTCc), the line that casts the
COLORREF (ie DWORD) variable to a BYTE throws the following
Run-Time Check Failure #1 even though its an explicit cast:
Run-Time Check Failure #1 - A cast to a smaller data type has
caused a loss of data. If this was intentional, you should mask
the source of the cast with the appropriate bitmask. For
example: char c = (i & 0xFF); Changing the code in this way will
not affect the quality of the resulting optimized code.
I tried following code with VC++2008 SP1:
// RGB.cpp
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <stdio.h>
int main()
{
COLORREF c=RGB(255,255,255);
BYTE a=GetRValue(c);
BYTE b=GetRValue(RGB(255,255,255));
printf("a=%d, b=%d", a, b);
return 0;
}
This is the command-line session:
C:\VSProjects>cl /RTCc RGB.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version
15.00.30729.01 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
RGB.cpp
Microsoft (R) Incremental Linker Version 9.00.30729.01
Copyright (C) Microsoft Corporation. All rights reserved.
/out:RGB.exe
RGB.obj
C:\VSProjects>RGB
a=255, b=255
Could you post a minimal example that triggers the run-time error?
Alex
.
- References:
- ? Run-Time Check Failure #1 with Built-In RGB Functions
- From: Alec S.
- Re: ? Run-Time Check Failure #1 with Built-In RGB Functions
- From: Alex Blekhman
- Re: ? Run-Time Check Failure #1 with Built-In RGB Functions
- From: Alec S.
- ? Run-Time Check Failure #1 with Built-In RGB Functions
- Prev by Date: Re: map
- Next by Date: Re: Template vector deleting destructor weak reference causes unexpected object files to be loaded
- Previous by thread: Re: ? Run-Time Check Failure #1 with Built-In RGB Functions
- Next by thread: Re: ? Run-Time Check Failure #1 with Built-In RGB Functions
- Index(es):
Relevant Pages
|