Skip to content

[BUG] Missing _template-head_ in static data member definition #698

Closed

Description

@JohelEGP

Title: Missing template-head in static data member definition.

Minimal reproducer (https://cpp2.godbolt.org/z/M6fr97sTY):

t: @struct <T: type> type = {
  v: int == 0;
}
main: () = { }
Commands:
cppfront main.cpp2
clang++17 -std=c++23 -stdlib=libc++ -lc++abi -pedantic-errors -Wall -Wextra -Wconversion -Werror=unused-result -I . main.cpp

Expected result:

template<typename T>
  inline constexpr int t::v = 0;

Actual result and error:

  inline constexpr int t::v = 0;
Cpp2 lowered to Cpp1:
//=== Cpp2 type declarations ====================================================


#include "cpp2util.h"

template<typename T> class t;
  

//=== Cpp2 type definitions and function declarations ===========================

template<typename T> class t {
  public: static const int v;
};
auto main() -> int;


//=== Cpp2 function definitions =================================================


  inline constexpr int t::v = 0;

auto main() -> int{}
Output:
main.cpp2:2:24: error: use of class template 't' requires template arguments
    2 |   inline constexpr int t::v = 0;
      |                        ^
build/main.cpp:13:28: note: template is declared here
   13 | template<typename T> class t {
      | ~~~~~~~~~~~~~~~~~~~~       ^
1 error generated.

Activity

  1. JohelEGP commented on Oct 3, 2023

    @JohelEGP
    ContributorAuthor

    On main, these are the new results (https://cpp2.godbolt.org/z/s31xsTj18).

    Actual result and error:

      template<typename T> inline CPP2_CONSTEXPR int<T> t<T>::v = 0;
    Output:
    main.cpp2:2:49: error: expected unqualified-id
        2 |   template<typename T> inline CPP2_CONSTEXPR int<T> t<T>::v = 0;
          |                                                 ^
    1 error generated.
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions