www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10582] New: Programmed and Compiler generated symbols clash.

reply d-bugmail puremagic.com writes:
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



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: -------
Jul 09 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10582


yebblies <yebblies gmail.com> changed:

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



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: -------
Aug 20 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10582


Dicebot <public dicebot.lv> changed:

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



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: -------
Aug 20 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10582


Iain Buclaw <ibuclaw ubuntu.com> changed:

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




 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: -------
Aug 20 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10582






 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: -------
Aug 20 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10582




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: -------
Aug 20 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10582




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: -------
Aug 20 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10582




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: -------
Aug 20 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10582




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: -------
Aug 21 2013