www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5930] New: cas doesn't work when used in code compiled with -D

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5930

           Summary: cas doesn't work when used in code compiled with -D
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: druntime
        AssignedTo: nobody puremagic.com
        ReportedBy: jsancio gmail.com



$ cat cas_test.d
import core.atomic;
import std.exception;
import std.stdio;

unittest
{
   shared bool init = false;
writefln("init = %s", init);
   enforce(cas(&init, false, true));
writefln("init = %s", init);
}

void main() {}

$ dmd -unittest cas_test.d && ./cas_test
init = false
init = true
$ dmd -unittest -D cas_test.d && ./cas_test
init = false
object.Exception cas_test.d(9): Enforcement failed
----------------
./cas_test(_D3std9exception7bailOutFAyaixAaZv+0x5b) [0x80a0dcb]
./cas_test(_D3std9exception45__T7enforceTbVAyaa10_6361735f746573742e64Vi9Z7enforceFbLAxaZb+0x2b)
[0x80985ff]
./cas_test(_D8cas_test11__unittest1FZv+0x39) [0x80954dd]
./cas_test(_D8cas_test9__modtestFZv+0x8) [0x80987bc]
./cas_test(_D4core7runtime18runModuleUnitTestsUZb16__foreachbody247MFKPS6object10ModuleInfoZi+0x24)
[0x80a3e1c]
./cas_test(_D6object10ModuleInfo7opApplyFMDFKPS6object10ModuleInfoZiZi+0x46)
[0x809a872]
./cas_test(runModuleUnitTests+0x87) [0x80a3d37]
./cas_test(_D2rt6dmain24mainUiPPaZi6runAllMFZv+0x20) [0x809b718]
./cas_test(_D2rt6dmain24mainUiPPaZi7tryExecMFMDFZvZv+0x20) [0x809b678]
./cas_test(main+0x94) [0x809b624]
/lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xe7) [0x126e37]
./cas_test() [0x80953f1]

-------------------------
Does this have to do with core/atomic.d having version(D_Doc) bool
cas(...)(...) {return false; }  ?


The work around is not to use object files compiled with the -D flag!

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 05 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5930


Sean Kelly <sean invisibleduck.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |sean invisibleduck.org



---
Yep.  This is because core.atomic has stub functions for documentation purposes
inside version(D_Ddoc) blocks.  There was some talk about Phobos and Druntime
moving to a different convention for documentation though.  I'll see about
fixing this for 2.054, since 2.053 is almost in the can.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 06 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5930


Rainer Schuetze <r.sagitario gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |r.sagitario gmx.de



PDT ---
phobos now uses version StdDdoc instead of D_Ddoc to fix similar issues.

Grep tells me core.atomic is the only module in druntime that uses
version(D_ddoc).

What needs to be done is:
- add -version=DruntimeDdoc or similar to DOCFMT in the makefiles
- use version(DruntimeDdoc) instead of version(D_Ddoc)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 06 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5930


Yao Gomez <yao.gomez gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
                 CC|                            |yao.gomez gmail.com



pull https://github.com/D-Programming-Language/druntime/pull/146

Uses the solution proposed by Rainer Schuetze. Instead of DruntimeDdoc, it uses
CoreDdoc.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 06 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5930


Kapps <opantm+spam gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |opantm+spam gmail.com



*** Issue 7528 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 23 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5930


Kapps <opantm+spam gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         OS/Version|Linux                       |All




 *** Issue 7528 has been marked as a duplicate of this issue. ***
As mentioned in 7528, this also has the unpleasant side-effect that attempting to use atomic operations (through core.atomic.atomicOp) silently results in incorrect behaviour, as the operations do nothing and return init. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 23 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5930


Kapps <opantm+spam gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |major



This bug really needs to get fixed for 2.059. It causes incorrect code to be
generated and code to silently fail, in ways that may be difficult to track
down and occur rarely (namely, when atomicOp is used).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 21 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5930


Matt Peterson <revcompgeek gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |revcompgeek gmail.com



PDT ---
Wouldn't it be better to put a "static assert(false);" in the body of those
Ddoc function stubs instead of "return false;"? Then it would become
immediately obvious what is wrong if they are used.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 22 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5930


dawg dawgfoto.de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dawg dawgfoto.de



Doc functions shouldn't need a body at all.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 20 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5930


dawg dawgfoto.de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED



https://github.com/D-Programming-Language/druntime/commit/8257db0291e2866a6c9ed1f0048e65b57fc33ca1

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 20 2012