[vtk-developers] [VTK 0013781]: CLang 3.3 prerelease confused by use of alloca in vtkVRML

Mantis Bug Tracker mantis at public.kitware.com
Fri Jan 11 10:40:24 EST 2013


The following issue has been SUBMITTED. 
====================================================================== 
http://vtk.org/Bug/view.php?id=13781 
====================================================================== 
Reported By:                kentwilliams
Assigned To:                
====================================================================== 
Project:                    VTK
Issue ID:                   13781
Category:                   (No Category)
Reproducibility:            have not tried
Severity:                   minor
Priority:                   normal
Status:                     backlog
Project:                    TBD 
Type:                       incorrect functionality 
Resolution:                 open
Fixed in Version:           
====================================================================== 
Date Submitted:             2013-01-11 10:40 EST
Last Modified:              2013-01-11 10:40 EST
====================================================================== 
Summary:                    CLang 3.3 prerelease confused by use of alloca in
vtkVRML
Description: 
This is a problem I detected using the CLang trunk revision (Version 3.3
pre-release), though the fix I'm suggesting will work with any CLang version. 
The problem stems from CLang's impersonation of GCC -- in other words CLang
defines __GNUC__ even though it diverges from GNUC behavior in several ways.

The compile error is this, and is followed by a patch that allows compilation to
complete.

/usr/include/alloca.h:36:7: error: declaration of '__builtin_alloca' has a
different language linkage
void    *alloca(size_t);                /* built-in for gcc */
         ^
/Volumes/scratch/kent/BRAINSStandalone/clangbuild/VTK/Hybrid/vtkVRMLImporter.cxx:14:16:
note: 
      expanded from macro 'alloca'
#define alloca __builtin_alloca
               ^
/usr/include/alloca.h:36:7: note: previous implicit declaration is here
/Volumes/scratch/kent/BRAINSStandalone/clangbuild/VTK/Hybrid/vtkVRMLImporter.cxx:14:16:
note: 
      expanded from macro 'alloca'
#define alloca __builtin_alloca
               ^
1 error generated.




diff --git a/Hybrid/vtkVRMLImporter.cxx b/Hybrid/vtkVRMLImporter.cxx
index ae6f239..2fd15a4 100644
--- a/Hybrid/vtkVRMLImporter.cxx
+++ b/Hybrid/vtkVRMLImporter.cxx
@@ -10,8 +10,10 @@
 
 
 #ifdef __GNUC__
+#ifndef __clang__
 #undef alloca
 #define alloca __builtin_alloca
+#endif
 #else /* not __GNUC__ */
 #if HAVE_ALLOCA_H
 #include <alloca.h>

====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2013-01-11 10:40 kentwilliams   New Issue                                    
======================================================================




More information about the vtk-developers mailing list