Thread overview
[Issue 10582] New: Programmed and Compiler generated symbols clash.
Jul 09, 2013
Iain Buclaw
Aug 20, 2013
yebblies
Aug 20, 2013
Dicebot
Aug 20, 2013
Iain Buclaw
Aug 20, 2013
Iain Buclaw
Aug 20, 2013
yebblies
Aug 20, 2013
Dicebot
Aug 20, 2013
Iain Buclaw
Aug 21, 2013
Don
July 09, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10582

           Summary: Programmed and Compiler generated symbols clash.
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: ibuclaw@ubuntu.com


--- Comment #0 from Iain Buclaw <ibuclaw@ubuntu.com> 2013-07-09 09:46:05 PDT ---
This is more of a pathological case, but produces an unexpected error nonetheless.  Ditto for any other type of compiler generated temporary symbol.


struct Bug
{
    ~this() { }
    int opApply(in int delegate(int i) dg) { return 0; }
}

void main()
{
  int __sl5;
  int __sl6;
  foreach (i; Bug()) {} // Error: declaration __sl6 is already defined
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 20, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10582


yebblies <yebblies@gmail.com> changed:

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


--- Comment #1 from yebblies <yebblies@gmail.com> 2013-08-21 00:45:18 EST ---
From http://dlang.org/lex.html

"Identifiers starting with __ (two underscores) are reserved"

I don't know what else _could_ happen here.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 20, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10582


Dicebot <public@dicebot.lv> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |public@dicebot.lv


--- Comment #2 from Dicebot <public@dicebot.lv> 2013-08-20 07:50:36 PDT ---
Probably it should be a compile-time error to even attempt to define a symbol which identifier starts with "__"?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 20, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10582


Iain Buclaw <ibuclaw@ubuntu.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ibuclaw@ubuntu.com


--- Comment #3 from Iain Buclaw <ibuclaw@ubuntu.com> 2013-08-20 07:53:45 PDT ---
(In reply to comment #2)
> Probably it should be a compile-time error to even attempt to define a symbol which identifier starts with "__"?

You can't do that. eg: gdc defines internal library functions beginning with '__', such as __gdc_personality_sj0/__gdc_personality_v0

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 20, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10582



--- Comment #4 from Iain Buclaw <ibuclaw@ubuntu.com> 2013-08-20 07:55:58 PDT ---
(In reply to comment #3)
> (In reply to comment #2)
> > Probably it should be a compile-time error to even attempt to define a symbol which identifier starts with "__"?
> 
> You can't do that. eg: gdc defines internal library functions beginning with '__', such as __gdc_personality_sj0/__gdc_personality_v0

And there's quite a few symbols in core.stdc that use __

Picking out a few from grep:

___pthread_cond_flags __pthread_cond_flags;
c_long __align;
enum __SIZEOF_PTHREAD_BARRIER_T = 20;

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 20, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10582



--- Comment #5 from yebblies <yebblies@gmail.com> 2013-08-21 01:00:11 EST ---
Soo...  we don't have many options really.

- leave it as is
- add a warning
- use 40000 leading underscores and/or obscure prefixes

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 20, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10582



--- Comment #6 from Dicebot <public@dicebot.lv> 2013-08-20 08:02:15 PDT ---
Ah, it is probably a minor issues with the spec too then - it does not state _for what_ those are reserved. I'd expect it to be reserved by compiler but looks like it is closer to "reserved by compiler, core lib and people who know what they are doing" ;)

I don't see what can be done with this bug report in this case.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 20, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10582



--- Comment #7 from Iain Buclaw <ibuclaw@ubuntu.com> 2013-08-20 08:04:21 PDT ---
One possible suggestion is for compiler generated symbols to check for collisions with user code in the same scope.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 21, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10582



--- Comment #8 from Don <clugdbug@yahoo.com.au> 2013-08-21 00:50:12 PDT ---
I don't think we should attempt to do anything about this.
"Using a symbol beginning with a double underscore voids your warranty."

It's like complaining that your power supply became unsafe after you pulled it apart. Well, you shouldn't be messing with it unless you're an electrician.

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