Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-14443] [C++] Don't crash on invalid dependent values. #56799

Open
zoecarver opened this issue Apr 3, 2021 · 6 comments
Open

[SR-14443] [C++] Don't crash on invalid dependent values. #56799

zoecarver opened this issue Apr 3, 2021 · 6 comments

Comments

@zoecarver
Copy link
Collaborator

@zoecarver zoecarver commented Apr 3, 2021

Previous ID SR-14443
Radar rdar://problem/83367285
Original Reporter @zoecarver
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CxxInterop, StarterBug
Assignee Rajagopalan (JIRA)
Priority Medium

md5: f34665bb62c6ff5d157cb3bd483d8006

Issue Description:

A while theindigamer (JIRA User) found this compiler crasher and I never got around to fixing it or creating a bug for it.

struct S {};
template <class T>
 struct IsSubtypeSame {
   static constexpr const S value = T();
};

using Invalid = IsSubtypeSame<int>;
@zoecarver
Copy link
Collaborator Author

@zoecarver zoecarver commented Apr 3, 2021

thomassw66 (JIRA User) this might be another interesting one to look at. It should just be a matter of finding the condition that causes this crash and then bailing on it.

@swift-ci
Copy link
Collaborator

@swift-ci swift-ci commented Aug 10, 2021

Comment by Rajagopalan Gangadharan (JIRA)

@zoecarver theindigamer (JIRA User) I would like to work on this, is there any details that I might find useful. Please do drop a comment. Thank you!

@swift-ci
Copy link
Collaborator

@swift-ci swift-ci commented Aug 10, 2021

Comment by Rajagopalan Gangadharan (JIRA)

Upon executing this I was not able to crash the compiler Instead I got a bunch of errors. Does this example needs some tweaking?

crash.swift:2:9: error: consecutive statements on a line must be separated by ';'
template <class T>
        ^
        ;
crash.swift:2:11: error: expected expression
template <class T>
          ^
crash.swift:2:18: error: expected '{' in class
template <class T>
                 ^
crash.swift:4:11: error: expected 'func' keyword in static method declaration
   static constexpr const S value = T();
          ^
          func
crash.swift:4:21: error: found an unexpected second identifier in function declaration; is there an accidental break?
   static constexpr const S value = T();
                    ^
crash.swift:4:21: note: join the identifiers together
   static constexpr const S value = T();
          ~~~~~~~~~~^~~~~
          constexprconst
crash.swift:4:21: note: join the identifiers together with camel-case
   static constexpr const S value = T();
          ~~~~~~~~~~^~~~~
          constexprConst
crash.swift:4:27: error: expected '(' in argument list of function declaration
   static constexpr const S value = T();
                          ^
crash.swift:4:26: error: consecutive declarations on a line must be separated by ';'
   static constexpr const S value = T();
                         ^
                         ;
crash.swift:4:27: error: expected declaration
   static constexpr const S value = T();
                          ^
crash.swift:3:9: note: in declaration of 'IsSubtypeSame'
 struct IsSubtypeSame {
        ^
crash.swift:7:6: error: consecutive statements on a line must be separated by ';'
using Invalid = IsSubtypeSame<int>;
     ^
     ;
crash.swift:2:1: error: cannot find 'template' in scope
template <class T>
^~~~~~~~
crash.swift:4:11: error: expected '{' in body of function declaration
   static constexpr const S value = T();
          ^
crash.swift:7:1: error: cannot find 'using' in scope
using Invalid = IsSubtypeSame<int>;
^~~~~
crash.swift:7:7: error: cannot find 'Invalid' in scope
using Invalid = IsSubtypeSame<int>;
      ^~~~~~~

@zoecarver
Copy link
Collaborator Author

@zoecarver zoecarver commented Aug 10, 2021

Hey Rajagopalan (JIRA User)! Happy to have you work on this. Feel free to reach out to me if you get stuck or want some help.

> Upon executing this I was not able to crash the compiler Instead I got a bunch of errors. Does this example needs some tweaking?

Is it possible that you're putting the C++ code in a Swift file? If so, what you are going to need to do is create a C++ header file and a module map. Then `import Test` the C++ module. You can see an example of this in the `swift/test/Interop/Cxx/namespace` where we have the C++ headers in `namespace/Inputs/<>.h`, the module map in `namespace/Inputs/module.modulemap`, and the Swift files in `namespace/<>.swift`.

@swift-ci
Copy link
Collaborator

@swift-ci swift-ci commented Aug 10, 2021

Comment by Rajagopalan Gangadharan (JIRA)

@zoecarver Thank you for correcting my stupid mistake 😛. Will do this and let you know how this goes.

@zoecarver
Copy link
Collaborator Author

@zoecarver zoecarver commented Sep 21, 2021

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants