Bug 68012 - g++ incorrectly accepts forward declaration of constexpr variable template
Summary: g++ incorrectly accepts forward declaration of constexpr variable template
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 5.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL: http://stackoverflow.com/q/33197817/1...
Keywords: diagnostic
Depends on:
Blocks: constexpr
  Show dependency treegraph
 
Reported: 2015-10-19 00:23 UTC by Morwenn
Modified: 2019-12-17 20:42 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2015-10-19 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Morwenn 2015-10-19 00:23:37 UTC
I had the following piece of code in one of my projects:

    template<typename>
    constexpr std::size_t iterator_category_value;

g++5.2 is happy with it but clang is not and complains, saying that it shouldn't be possible to forward-declare a constexpr whatever. To be sure, I asked the question on StackOverflow: http://stackoverflow.com/q/33197817/1364752

It seems that this code should not be accepted, and a defect report seems to agree that it should be rejected: http://wg21.cmeerw.net/cwg/issue1712
Comment 1 Jason Merrill 2019-12-17 20:42:54 UTC
This seems like an ill-formed, no diagnostic required situation because no valid specialization can be generated; if you try to instantiate the template, G++ complains then.  I agree that giving a diagnostic would be better, but the conformance issue is that G++ allows you to redefine it (PR 92576).