bug in wingdi.h ?

Hello,

could someone verify this is bug :

#define GetGValue(rgb) (LOBYTE(((WORD)(rgb)) >> 8))

Atleast for me it throws runtime-check-error when used.

"""
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.
"""

Change to

#define C_GetGValue(rgb) (LOBYTE(((WORD)(rgb&0xFFFF)) >> 8))

helps, so it seems like a small bug in headers to me. I wouldn't like to spam the Microsoft Connect with this though...

Regards,
Martin




Answer this question

bug in wingdi.h ?

  • CBHCMC

    This macro is only suitable for use in unmanaged code.


  • My Name is Adam

     nobugz wrote:
    Sad.  This problem was already reported in the Beta 1 version but still not fixed.  The bug report however offers a reasonable workaround:
    #include <windows.h>
    #undef GetGValue
    #define GetGValue(rgb) ((BYTE)(((rgb)&0xFF00)>>8))

    Could be that no one validated it or voted for it before Whidbey was frozen.  If no one votes or validates a feedback entry then it basically gets ignored, unless there's nothing else to do (and I don't think that will happen any time soon with Visual Studio).

  • Chewy&amp;#33;

    Of course, I'm using unmanaged code. No MFC. No ATL.

    Or to be exact - I link MFC as static lib, but do not use anything from it (except debug support)

    VS2005 Professional.



  • Vasura

    BTW, that warning is safe to ignore, in the meantime.

  • Lorry Craig

    maliger wrote:
    btw: I think MVP should have atleast 5 votes! After all, you had a value, don't you :-)
    BTW, if you have opinions on the Connect site in general, or specific opinions about what MVPs should be able to do or should be doing on the site, you can voice your opinion at http://connect.microsoft.com/Connect/Feedback

  • Steve Russell

    I dont think either :-) So go to vote!

    btw: I think MVP should have atleast 5 votes! After all, you had a value, don't you :-)



  • SWGuy

    Seems worthy of a bug report to me. While the the code analysis is only outputting a warning, and GetGValue has been around for a dozen or so years; it should still run without error through the code analysis engines--which is a priority over at MS at the moment. Filing a bug report will make sure it doesn't get missed.

  • Lukke

    There was already 2 submissions on MS Connect on those:

    http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx FeedbackID=100961

    http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx FeedbackID=100797

    I voted and validated the former.

    Thanks for validation!

    Regards,
    Martin Aliger



  • Peter K

    Sad. This problem was already reported in the Beta 1 version but still not fixed. The bug report however offers a reasonable workaround:
    #include <windows.h>
    #undef GetGValue
    #define GetGValue(rgb) ((BYTE)(((rgb)&0xFF00)>>8))



  • jamesIEDOTNET

    maliger wrote:
    btw: I think MVP should have atleast 5 votes! After all, you had a value, don't you :-)
    In the old system (MSDN Product Feedback Center) issues logged by MVPs were uniquely recognized as being logged by an MVP and need not be validated. The new system is not currently the same in that respect.

  • bug in wingdi.h ?