# Tests of #EZ5 don't correspond to local

**URL:** <https://forum.codecrafters.io/t/tests-of-ez5-dont-correspond-to-local/4467>\
**Category:** Challenges\
**Tags:** challenge:shell\
**Created:** [January 25, 2025, 7:49pm UTC](https://forum.codecrafters.io/t/tests-of-ez5-dont-correspond-to-local/4467 "2025-01-25T19:49:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pedrohfranco](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/pedrohfranco/32/4483_2.png) [@pedrohfranco](https://forum.codecrafters.io/u/pedrohfranco)\
**Post date:** [January 25, 2025, 7:49pm UTC](https://forum.codecrafters.io/t/tests-of-ez5-dont-correspond-to-local/4467/1 "2025-01-25T19:49:10Z")

</div>

Im stuck at stage #EZ5. Everytime I push it to the master branch, it says my code is returning “”, even if locally everything is alright.

I could just copy the code from one of the examples, but I wanted to stick to what I did alone and I want to know if it’s anything I’ve done wrong or it’s fault of the server side.

Here’s my [GitHub repo with the code](https://github.com/pedrohfranco/codecrafters-shell/blob/93876e8267719f988ce7f5cf2e8d37be5b1af62c/src).

---

<div class="post-metadata">

**Author:** ![guy-732](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/guy-732/32/3901_2.png) [@guy-732](https://forum.codecrafters.io/u/guy-732)\
**Post date:** [January 26, 2025, 3:53am UTC](https://forum.codecrafters.io/t/tests-of-ez5-dont-correspond-to-local/4467/2 "2025-01-26T03:53:46Z")

</div>

The for loop in your function `type()` does out of bounds access on the array (`sizeof(builtin)` is the size of `Builtin` times number of elements in the array… and not just the number of elements in the array)

So instead of:

```cpp
builtinTypes type(string args) {
  for(int i = 0; i < sizeof(builtin); i++) {
...

```

You do this:

```cpp
builtinTypes type(string args) {
  for(int i = 0; i < (sizeof(builtin) / sizeof(Builtin)); i++) {
...

```

**Note:** the codecrafter testers will immediatly abort the program with exit code `-1` if it **EVER** dereference memory that is not allocated (out of bounds array access for example)  
Honestly could get some clarification that a memory error was detected…

You can use `valgrind` to check if your program has memory errors or not

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/7/0/700657133935c15703e22c7c8870394f6e6dc27d.svg) [@system](https://forum.codecrafters.io/u/system)\
**Post date:** [January 31, 2025, 3:53am UTC](https://forum.codecrafters.io/t/tests-of-ez5-dont-correspond-to-local/4467/3 "2025-01-31T03:53:53Z")

</div>

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