Quantcast
Channel: Intel® Software - Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1175

BUG For constexpr in Templates

$
0
0

The following code does not compile with ICC (versions below) but does with GCC was already posted on StackOverflow

class Constants {
   static constexpr int value_ = 2;

public:
   static constexpr inline int V() { return value_; }
};

typedef Constants CC;

template<int N>
class Terror {
public:
  template<class T>
  void F(T (&a)[CC::V()]) {}
};

int main() {
  int array[CC::V()];
  Terror<42> ter = Terror<42>();
  ter.F(array);
}

Tested with:

Intel(R) C Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 16.0.4.258 Build 20160811
Copyright (C) 1985-2016 Intel Corporation.  All rights reserved.

and

Intel(R) C Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 18.0.0.128 Build 20170811
Copyright (C) 1985-2017 Intel Corporation.  All rights reserved.

Viewing all articles
Browse latest Browse all 1175

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>