[PATCH] D17103: [CUDA] Don't crash when trying to printf a non-scalar object.
    Justin Lebar via cfe-commits 
    cfe-commits at lists.llvm.org
       
    Wed Feb 10 15:57:51 PST 2016
    
    
  
jlebar added a comment.
> > I guess this is the part I'm unsure of.  If it's legal to pass a struct to printf in regular C++ (seems to be?), I'd guess it should be legal in CUDA, too?  I'm just not sure what it's supposed to do (in either case).
> 
> 
> Is this because PTX does not have a way to represent va_arg structs?
We do build up something that looks an awful lot like a va_arg struct in this function.  (It's a struct with N members, one for each of the varargs.)  Exactly what printf expects is not particularly carefully specified in the nvvm documentation.
If an arg to printf is non-scalar, we could pass the whole thing into the struct we build here, but that doesn't seem to be what regular C++ does (it seems to take the first 64 bits of the struct -- I have no idea if this is specified somewhere or just UB).
http://reviews.llvm.org/D17103
    
    
More information about the cfe-commits
mailing list