Thread overview
[Issue 5930] New: cas doesn't work when used in code compiled with -D
May 05, 2011
Jose Garcia
May 06, 2011
Sean Kelly
May 07, 2011
Rainer Schuetze
Feb 07, 2012
Yao Gomez
Feb 23, 2012
Kapps
Feb 23, 2012
Kapps
Mar 21, 2012
Kapps
Mar 22, 2012
Matt Peterson
May 20, 2012
dawg@dawgfoto.de
May 20, 2012
dawg@dawgfoto.de
May 05, 2011
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


--- Comment #0 from Jose Garcia <jsancio@gmail.com> 2011-05-05 12:03:54 PDT ---
$ 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 06, 2011
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


--- Comment #1 from Sean Kelly <sean@invisibleduck.org> 2011-05-06 10:46:30 PDT ---
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 07, 2011
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


--- Comment #2 from Rainer Schuetze <r.sagitario@gmx.de> 2011-05-06 23:31:50 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: -------
February 07, 2012
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


--- Comment #3 from Yao Gomez <yao.gomez@gmail.com> 2012-02-06 18:08:38 PST ---
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: -------
February 23, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=5930


Kapps <opantm+spam@gmail.com> changed:

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


--- Comment #4 from Kapps <opantm+spam@gmail.com> 2012-02-23 01:07:09 PST ---
*** 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: -------
February 23, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=5930


Kapps <opantm+spam@gmail.com> changed:

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


--- Comment #5 from Kapps <opantm+spam@gmail.com> 2012-02-23 01:10:34 PST ---
(In reply to comment #4)
> *** 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: -------
March 21, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=5930


Kapps <opantm+spam@gmail.com> changed:

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


--- Comment #6 from Kapps <opantm+spam@gmail.com> 2012-03-21 13:59:41 PDT ---
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: -------
March 22, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=5930


Matt Peterson <revcompgeek@gmail.com> changed:

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


--- Comment #7 from Matt Peterson <revcompgeek@gmail.com> 2012-03-22 13:02:14 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: -------
May 20, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=5930


dawg@dawgfoto.de changed:

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


--- Comment #8 from dawg@dawgfoto.de 2012-05-20 12:21:25 PDT ---
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
http://d.puremagic.com/issues/show_bug.cgi?id=5930


dawg@dawgfoto.de changed:

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


--- Comment #9 from dawg@dawgfoto.de 2012-05-20 12:21:43 PDT ---
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: -------