[PATCH] Unknown-bound array static data member of template should be type dependent

Richard Smith richard at metafoo.co.uk
Wed Nov 13 13:47:21 PST 2013


  Yes, go ahead. Thanks!


================
Comment at: test/CXX/drs/dr4xx.cpp:8
@@ +7,3 @@
+namespace dr408 { // dr408: yes
+  template <int> void g();
+  template <> void g<2>() { }
----------------
Can you put something in the definition of this that will fail if it gets instantiated? Something like:

  template<int N> void g() { int arr[N == 12345 ? 1 : -1]; }

================
Comment at: test/CXX/drs/dr4xx.cpp:33
@@ +32,3 @@
+
+#if __cplusplus >= 201103L
+  template<typename T> struct R {
----------------
Instead of making this C++11-only, please replace the `static_assert` with a check that also works in C++98 mode. Like:

  int arr[sizeof(arr) != sizeof(int) ? 1 : -1];


http://llvm-reviews.chandlerc.com/D2049



More information about the cfe-commits mailing list