-
Notifications
You must be signed in to change notification settings - Fork 170
Fix string indexing #273
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
Comments
C++ code for reference: #include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <cmath>
#include <Kokkos_Core.hpp>
#include <lfortran_intrinsics.h>
template <typename T>
Kokkos::View<T*> from_std_vector(const std::vector<T> &v)
{
Kokkos::View<T*> r("r", v.size());
for (size_t i=0; i < v.size(); i++) {
r(i) = v[i];
}
return r;
}
void _lpython_main_program()
{
f();
}
void f()
{
std::string s;
s = "abcdefg";
std::cout << s[1 + 1-1] << std::endl;
std::cout << s[2 + 1-1] << std::endl;
std::cout << s[3 + 1-1] << std::endl;
}
namespace {
void main2() {
_lpython_main_program();
}
}
int main(int argc, char* argv[])
{
Kokkos::initialize(argc, argv);
main2();
Kokkos::finalize();
return 0;
} |
We should improve it as well. |
I guess the problem is here: lpython/src/libasr/codegen/asr_to_llvm.cpp Lines 1029 to 1043 in 3104565
|
This issue might be easier to handle once we move forward with: https://gitlab.com/lfortran/lfortran/-/merge_requests/1700 |
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The following code:
Prints (correctly) using CPython:
But with LPython it prints:
We have to fix it.
The text was updated successfully, but these errors were encountered: