[PATCH] D34096: [Sema][C++1z] Ensure structured binding's bindings in dependent foreach have non-null type

Benjamin Buch via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 16 10:50:56 PDT 2017


bebuch reopened this revision.
bebuch added a comment.
This revision is now accepted and ready to land.

I believe this patch is incomplete, I get a very odd warning:

  struct A{
      int x;
  };
  
  template < typename >
  struct B{
      A data_[1];
  
      void f(){
          for(auto [x]: data_){
              (void)x;
          }
      }
  };
  
  int main(){
  	B< int > v;
  	v.f();
  }



  $ clang++ -std=c++1z -Wall clang_fail.cpp                                                                                                                                                                                
  clang_fail.cpp:10:18: warning: unused variable '' [-Wunused-variable]                                                                                                                                                                                                 
          for(auto [x]: data_){                                                                                                                                                                                                                                         
                   ^                                                                                                                                                                                                                                                    
  clang_fail.cpp:18:4: note: in instantiation of member function 'B<int>::f' requested here                                                                                                                                                                             
          v.f();                                                                                                                                                                                                                                                        
            ^                                                                                                                                                                                                                                                           
  1 warning generated.

unused variable ''? An unnamed variable, that's odd ;-)

Nevertheless, thanks for what is already done! Great that I can use structured bindings without fear to crash now! :-)


Repository:
  rL LLVM

https://reviews.llvm.org/D34096





More information about the cfe-commits mailing list