Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9290107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T20:20:21+00:00 2026-06-18T20:20:21+00:00

The offending code: template <class Bar, size_t MAX_SIZE = std::numeric_limits<size_t>::max()> size_t foo(Bar const& b)

  • 0

The offending code:

template <class Bar, 
         size_t MAX_SIZE = std::numeric_limits<size_t>::max()>
size_t foo(Bar const& b) { omitted... }

It compiles fine on gcc 4.7.2 with -std=c++11. On clang 3.0 I get the following error:

foo.hpp:35:28: error: non-type template argument of type 'unsigned long' is not an integral constant expression
         size_t MAX_SIZE = std::numeric_limits<size_t>::max()>
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

As far as I can tell, I am supposed to be able to use numeric_limits in this way in c++11. Is clang wrong here, or am I unaware of something?

EDIT:

Compilation flags are: clang++ -o foo.o -c -W -Wall -Wextra -Werror -std=c++11 -stdlib=libc++ -g -I. foo.cpp

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T20:20:22+00:00Added an answer on June 18, 2026 at 8:20 pm

    Your code compiles just fine with clang++ 3.2, see here.

    I would say there is nothing wrong with your code but you should upgrade to a newer version of clang.

    Note: The code doesn’t compile with the Intel C++ Compiler 13.0.1 due to a compiler bug (thanks @Xeo):

    Compilation finished with errors:
    source.cpp(6): internal error: assertion failed: ensure_il_scope_exists: NULL IL scope (shared/cfe/edgcpfe/il.c, line 7439)
    
    size_t MAX_SIZE = std::numeric_limits<size_t>::max()>
    ^
    
    compilation aborted for source.cpp (code 4)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this class is much larger, but i'll just post the offending code. template<class T>
The offending code: template<typename T> class SharedObject { public: typedef boost::intrusive_ptr<T> Pointer; typedef boost::intrusive_ptr<T
I have a problem with a piece of code of the following form: template<class
I'm getting a really strange NPE exception. This is the offending code: private static
I've got a program that worked until recently. The offending code is shown here:
I was trying to compile some code that uses Boost (1.49), with Clang(& libc++)
Here's the offending code: repeat with this_indd_jpeg in indd_jpeg_list set original_name to name of
Larry Osterman writes about a real error found in Microsoft's code, the offending code
Ok so I've got this piece of offending code: <!-- Begin the Product Group
I am having some weird performance issues with evalRandIO. Here's the offending code: import

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.