Path: utzoo!mnetor!uunet!husc6!mit-eddie!bbn!rochester!ur-tut!sunybcs!boulder!tramp!swarbric From: swarbric@tramp.Colorado.EDU (Frank Swarbrick) Newsgroups: comp.lang.c Subject: Re: noalias comments to X3J11 Message-ID: <5064@sigi.Colorado.EDU> Date: 25 Mar 88 00:31:24 GMT References: <7753@alice.UUCP> <4993@sigi.Colorado.EDU> <1988Mar23.193330.459@utzoo.uucp> Sender: news@sigi.Colorado.EDU Reply-To: swarbric@tramp.Colorado.EDU (Frank Swarbrick) Organization: University of Colorado, Boulder Lines: 25 In article <1988Mar23.193330.459@utzoo.uucp> henry@utzoo.uucp (Henry Spencer) writes: :>What does this const thing have to do with the function below getting the :>suspicious pointer conversion warning? :> :> return s ? (int)(s - str) : -1; : :You're mixing two separate types of pointer: s is char *, str is :const char *. THOSE ARE NOT THE SAME TYPE. Evidently the compiler :is doing the conversion for you, but it's not entirely happy about it. :In this particular case, adding const to the declaration of s would :fix it, pretty much. (The exact rules for this sort of thing may yet :change again before ANSI C is final.) I just changed it to return s ? s - (char *)str : -1; and it worked fine. Thanks for the idea, although you gave it indirectly and maybe without knowing it... (Actually I didn't run it, but it compiled without giving the warning.) Frank Swarbrick (and his cat) swarbric@tramp.UUCP swarbric@tramp.Colorado.EDU ...!{ncar|nbires}!boulder!tramp!swarbric "Remember when you were young. You shown like the sun..."