home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 32,651 of 33,346   
   Matt Calabrese to All   
   Re: Is this a violation of the ODR?   
   14 Nov 12 17:04:34   
   
   From: rivorus@googlemail.com   
      
   On Tuesday, November 13, 2012 6:02:26 PM UTC-5, SG wrote:   
   > Am 13.11.2012 08:14, schrieb Matt Calabrese:   
   > > ////////////////////   
   > > // namespace { bool foo(); }   
   > > // inline void bar() { decltype( foo() ) foobar; }   
   > > ////////////////////   
   > >   
   > > So, if the above code is inside of a header file that is included by   
   > > two or more different translation units, is the ODR technically still   
   > > violated? In other words, if I'm only doing something different in an   
   > > unevaluated context, but the resultant type is always the same in   
   > > every translation unit, is what I'm doing technically okay? Should I   
   > > worry about this even if it is questionable whether or not this is   
   > > valid? I don't see how this could possibly cause a problem, but for   
   > > the sake of being pedantic, I'd like to know if I'm committing one of   
   > > the worst of all C++ sins.   
   >   
   >    
   >   
   > I think you're violating the 2nd bullet point because the corresponding   
   > names "foo" across the translation units don't refer to the same entity   
   > since each translation unit has its own foo. On the other hand you're   
   > just using its return type which is is the same across all translation   
   > units. So, I guess that you won't run into any troubles. But still, it   
   > seems like an ODR violation to me, strictly speaking.   
      
   Yeah, this was exactly my conclusion, I was just sort of hoping that   
   someone would be able to convince me otherwise. In the end, I think I'm   
   going to count on it not causing problems, as much as it pains me to do   
   so. I know that this is always a crapshoot, but it's extremely tempting   
   here to just assume that it's fine. It seems very unlikely to me that   
   this type of situation was considered, and I doubt any implementations   
   would have issues with it.   
      
      
   --   
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca