www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - goto case warning

--001517493832c46b6104b196cc9d
Content-Type: text/plain; charset=ISO-8859-1

I'm getting an odd error message in line 366 below (this is part of
variant.d):

../utd/variant.d(366): Error: switch case fallthrough - use 'goto case;' if
intended


But you can see that line 366 already has a "goto case":

            switch(id) {
                foreach(i,T; ICT!A ) {
                    static if (is(typeof(*cast(T*) ptr = *src)) ) {
                        //    BUG     workaround the string <=>
immutable(char)[] problem
                        static if((is(T : const(char[])) || is(T :
const(wchar[])) || is(T : const(dchar[]))) &&
                                  T.stringof !=
(typeof(T.init[0])).stringof~"[]" ) {
                            case (typeof(T.init[0])).stringof~"[]": goto
case;
                        }

                        // isImplicitlyConvertible!(T,immutable T) [inlined]
                        static if( !is(immutable T == T)  &&
is(typeof({void fun(immutable(T)){} T f; fun(f);}())) ) {
                            case (immutable T).stringof: goto case;
                        }

                        static if(!is(const(T) == T) &&
!(i==1&&is(typeof(T.init[]))) ) {
                            case (const     T).stringof: goto case;  //    
THIS IS LINE 366
                        }
                            case (          T).stringof:
                                static if(is(T:Object)) {
                                    if(info !is typeid(T) && info !is
typeid(const T) && info !is typeid(immutable T) )
                                        continue;
                                }
                                if (src && ptr)
                                    *(cast(T*) ptr) = *src;
                                return true;
                    }
                }

Any help is appreciated, thanks
John

--001517493832c46b6104b196cc9d
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div>I&#39;m getting an odd error message in line 366 below (this is part o=
f variant.d):</div><div><br></div><blockquote style=3D"margin:0 0 0 40px;bo=
rder:none;padding:0px"><div><div><font face=3D"&#39;courier new&#39;, monos=
pace">../utd/variant.d(366): Error: switch case fallthrough - use &#39;goto=
 case;&#39; if intended</font></div>

</div></blockquote><div><br></div><div>But you can see that line 366 alread=
y has a &quot;goto case&quot;:</div><div><br></div><div><font face=3D"&#39;=
courier new&#39;, monospace">=A0 =A0 =A0 =A0 =A0 =A0 switch(id) {</font></d=
iv>
<div><font face=3D"&#39;courier new&#39;, monospace">=A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 foreach(i,T; ICT!A ) {</font></div><div><font face=3D"&#39;cour=
ier new&#39;, monospace">=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 static if =
(is(typeof(*cast(T*) ptr =3D *src)) ) {</font></div>

<div><font face=3D"&#39;courier new&#39;, monospace">=A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 //    BUG     workaround the string &lt;=3D&gt;=
 immutable(char)[] problem</font></div><div><font face=3D"&#39;courier new&=
#39;, monospace">=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 static if(=
(is(T : const(char[])) || is(T : const(wchar[])) || is(T : const(dchar[])))=
 &amp;&amp;</font></div>

<div><font face=3D"&#39;courier new&#39;, monospace">=A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 T.stringof !=3D (typeof(T.i=
nit[0])).stringof~&quot;[]&quot; ) {</font></div><div><font face=3D"&#39;co=
urier new&#39;, monospace">=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 case (typeof(T.init[0])).stringof~&quot;[]&quot;: goto case;</font>=
</div>

<div><font face=3D"&#39;courier new&#39;, monospace">=A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 }</font></div><div><font face=3D"&#39;courier n=
ew&#39;, monospace"><br></font></div><div><font face=3D"&#39;courier new&#3=
9;, monospace">=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 // isImplici=
tlyConvertible!(T,immutable T) [inlined]</font></div>

<div><font face=3D"&#39;courier new&#39;, monospace">=A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 static if( !is(immutable T =3D=3D T) =A0&amp;&a=
mp; is(typeof({void fun(immutable(T)){} T f; fun(f);}())) ) {</font></div><=
div><font face=3D"&#39;courier new&#39;, monospace">=A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 case (immutable T).stringof: goto case;</f=
ont></div>

<div><font face=3D"&#39;courier new&#39;, monospace">=A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 }</font></div><div><font face=3D"&#39;courier n=
ew&#39;, monospace"><br></font></div><div><font face=3D"&#39;courier new&#3=
9;, monospace">=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 static if(!i=
s(const(T) =3D=3D T) &amp;&amp; !(i=3D=3D1&amp;&amp;is(typeof(T.init[]))) )=
 {</font></div>

<div><font face=3D"&#39;courier new&#39;, monospace">=A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 case (const =A0 =A0 T).stringof: goto c=
ase; =A0//     THIS IS LINE 366</font></div><div><font face=3D"&#39;courier=
 new&#39;, monospace">=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }</fo=
nt></div>

<div><font face=3D"&#39;courier new&#39;, monospace">=A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 case ( =A0 =A0 =A0 =A0 =A0T).stringof:<=
/font></div><div><font face=3D"&#39;courier new&#39;, monospace">=A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 static if(is(T:Obje=
ct)) {</font></div>

<div><font face=3D"&#39;courier new&#39;, monospace">=A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if(info !is typeid(T) &=
amp;&amp; info !is typeid(const T) &amp;&amp; info !is typeid(immutable T) =
)</font></div>
<div><font face=3D"&#39;courier new&#39;, monospace">=A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 continue;</font=
</div><div><font face=3D"&#39;courier new&#39;, monospace">=A0 =A0 =A0 =A0=

<div><font face=3D"&#39;courier new&#39;, monospace">=A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (src &amp;&amp; ptr)</font><= /div><div><font face=3D"&#39;courier new&#39;, monospace">=A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 *(cast(T*) ptr) =3D= *src;</font></div> <div><font face=3D"&#39;courier new&#39;, monospace">=A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return true;</font></div><div><= font face=3D"&#39;courier new&#39;, monospace">=A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 }</font></div> <div><font face=3D"&#39;courier new&#39;, monospace">=A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 }</font></div><div><br></div><div>Any help is appreciated, than= ks</div><div>John</div> --001517493832c46b6104b196cc9d--
Nov 12 2011