C++ Errors getting ignored

Problem description:
In working on C++ I noticed that errors that should terminate the program (ArrayIndexOutOfBounds (Not sure if that is the exact name, but you get the point)) are ignored, and the program continues, acting on array[-24546466], which obviously should not happen.

Expected behavior:
The program terminates with an error message. (Letting me know that there is an issue as well, so I don’t continue on thinking everything is fine). I should also get a warning that a variable is being used without being initialized.

Actual behavior:
No errors or warnings, program plows ahead performing incorrectly.

Steps to reproduce:
You should just be able to write a program in C++ that tries to act on an out of bounds index.

Bug appears at this link:
I already described this issue here, but nobody was able to help me, so I think it is truly a bug. There is also a link to a repl that has this bug causing issues.

I’m going to assume this is a replit.com problem(browser).

This is not a bug, this is how C++ works. More specifically this is too do with how arrays and pointers work. Basically, an array is just a pointer to a fixed number of values, so by accessing the value at the pointer, -1, you just access a random value in the memory as whatever data type you assume it is.

In other words, arr[i], wherearr is an array and i is an index, is equivalent to*(arr + i), wherearr is a pointer to an array and i is an index.


This confuses me because VS Code had errors when compiling that program I shared. Why is it different there?
It’s not the only assignment that had errors in VS Code either. There were 2 or 3 other projects I had to share a replit link to my professor showing that it did indeed run.

It’s probably something to do with what compiler you’re using, your compiler is probably throwing an error because its been setup or designed to catch common mistakes which aren’t technically errors.


I’ve changed the category as this appears to be a setting difference rather than a bug. If you can @ThomasWarenski a screenshot of the errors that appear for you in VSCode would be helpful here as we might be able to suggest how to get the same to appear for you in Replit.


true, but I don’t see a reason for Makefile in the C++ template to contain a flag which disables all compiler warnings by default, and which is responsible for many code issues reported here and on Friends of Replit. So it is a bug, if this is one.
-Wno-everything in Makefile should be replaced with -Wmost -Werror, and the user can make that just -Wmost if they know what they’re doing.


Thanks @UMARismyname let me check with Replit support and confirm. Much appreciated!


Thank you for the recommendation! I will send this to the team and will see if this is something we can change.

1 Like

Problem description:

Can someone explain to me why the code I wrote at the following link works correctly? I wrote an output statement on an integer variable before assigning a value to it.

Plan: Free


This is my execution.
Why it prints out 10 ?
It makes no sense.

same issue as this post except you just have 10 and not 300


I started it with the command

g++ main.cpp -o main && ./main

and it works correctly, thank you.

1 Like

Hey all!

This was recently resolved and our C++ template has been updated to no longer ignore all C++ errors. Please let me know if you have any questions or if you are still seeing issues!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.