[Mono-bugs] [Bug 514096] New: CS0677 error on volatile IntPtr

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Jun 17 14:06:13 EDT 2009


http://bugzilla.novell.com/show_bug.cgi?id=514096


           Summary: CS0677 error on volatile IntPtr
    Classification: Mono
           Product: Mono: Compilers
           Version: 2.4.x
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: C#
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: ptrajkumar at gmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


User-Agent:       Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64;
Trident/4.0; SU 3.1; SLCC1; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.5.21022;
NET CLR 3.5.30729; .NET CLR 3.0.30729)

   I am applying a volatile keyword on IntPtr like this

private volatile IntPtr mNativeCancelRequest;

  And compiling against Mono 2.4 I get this error. 

error CS0677: `mNativeCancelRequest': A volatile field cannot be of the type
`System.IntPtr'

This seems like a bug according to the standard. As it explicitly allow this to
be done.


10.5.3 Volatile fieldsWhen a field-declaration includes a volatile modifier,
the fields introduced by that declaration are volatile fields. 
For non-volatile fields, optimization techniques that reorder instructions can
lead to unexpected and unpredictable results in multi-threaded programs that
access fields without synchronization such as that provided by the
lock-statement (§8.12). These optimizations can be performed by the compiler,
by the runtime system, or by hardware. For volatile fields, such reordering
optimizations are restricted: 
A read of a volatile field is called a volatile read. A volatile read has
“acquire semantics”; that is, it is guaranteed to occur prior to any references
to memory that occur after it in the instruction sequence. 
A write of a volatile field is called a volatile write. A volatile write has
“release semantics”; that is, it is guaranteed to happen after any memory
references prior to the write instruction in the instruction sequence.
These restrictions ensure that all threads will observe volatile writes
performed by any other thread in the order in which they were performed. A
conforming implementation is not required to provide a single total ordering of
volatile writes as seen from all threads of execution. The type of a volatile
field must be one of the following:
A reference-type.
The type byte, sbyte, short, ushort, int, uint, char, float, bool,
System.IntPtr, or System.UIntPtr.
An enum-type having an enum base type of byte, sbyte, short, ushort, int, or
uint.




Reproducible: Always

Steps to Reproduce:
1. Compile any class with an volative IntPtr
2.
3.
Actual Results:  
Compilation should succeed

Expected Results:  
Compilation error CS0677

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list