incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Sebor (JIRA)" <j...@apache.org>
Subject [jira] Created: (STDCXX-61) [MSVC] bad casts in __rw_atomic_xxx() functions
Date Tue, 01 Nov 2005 22:14:55 GMT
[MSVC] bad casts in __rw_atomic_xxx() functions
-----------------------------------------------

         Key: STDCXX-61
         URL: http://issues.apache.org/jira/browse/STDCXX-61
     Project: STDCXX
        Type: Bug
  Components: Build  
    Versions: 4.1.2    
 Environment: MSVC
    Reporter: Martin Sebor
 Assigned to: Martin Sebor 
     Fix For: 4.1.3


-------- Original Message --------
Subject: Problems in __rw_atomic_ operations for Win32 (_mutex.h)
Date: Tue, 1 Nov 2005 19:49:49 +0300
From: Anton Pevtsov <AntonP@moscow.vdiweb.com>
Reply-To: stdcxx-dev@incubator.apache.org
To: <stdcxx-dev@incubator.apache.org>

There is a problem in the __rw_atomic_preincrement function versions for
Win32 (see the include\rw\_mutex.h file, line 1352):

inline int
__rw_atomic_preincrement (int &__x, bool)
{
    _RWSTD_COMPILE_ASSERT (sizeof __x == sizeof (long));
    return InterlockedIncrement (_RWSTD_REINTERPRET_CAST (long*, __x));
}

This 

_RWSTD_REINTERPRET_CAST (long*, __x) 

tries to cast __x (not &__x !) to the long*.

After the casting the created temporary variable (to be passed to the
InterlockedIncrement function) contains the value of __x interpreted as
an valid address.
This results in that all stdcxx library examples crash. (They use
std::cout which uses these functions ?)

The same problem is in __rw_atomic_predecrement and
__rw_atomic_exchange.

Looks like instead of 

_RWSTD_REINTERPRET_CAST (long*, __x)

should be

_RWSTD_REINTERPRET_CAST (long*, &__x)

?


With best wishes,
Anton Pevtsov.


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


Mime
View raw message