title: is used uninitialized in this function [-Wuninitialized]
body: <p>I'm making a memory cache simulation on C++ and after a lot of coding im getting this error:</p>
  
  <pre><code>g++ main.cpp blocoMemoria.cpp endereco.cpp instrucao.cpp mmu.cpp maquina.cpp -o joubert.o -g -Wall
  
  main.cpp: In function ‘int main(int, const char**)’:
  
  main.cpp:18:29: warning: ‘ram’ is used uninitialized in this function [-Wuninitialized]
  BlocoMemoria *ram = gerarBM(ram, tamanhoRam);
                    ~~~~~~~^~~~~~~~~~~~~~~~~
  
  main.cpp:19:32: warning: ‘cache1’ is used uninitialized in this function [-Wuninitialized]
  BlocoMemoria *cache1 = gerarBM(cache1, tamanhoCache1);
                       ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
  
  main.cpp:20:32: warning: ‘cache2’ is used uninitialized in this function [-Wuninitialized]
  BlocoMemoria *cache2 = gerarBM(cache2, tamanhoCache2);
                       ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
  
  main.cpp:26:66: warning: ‘memoriaInstrucoes’ is used uninitialized in this function [-Wuninitialized]
  
  Instrucao *memoriaInstrucoes = montarInstrucoesProgramaAleatorio(memoriaInstrucoes, tamanhoPrograma, qdePalavrasBloco, tamanhoRam);
  </code></pre>
  
  <p>This is my main:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;bits/stdc++.h&gt;
  #include "endereco.hpp"
  #include "instrucao.hpp"
  #include "blocoMemoria.hpp"
  #include "mmu.hpp"
  #include "maquina.hpp"
  
  using namespace std;
  
  int main(int argc, char const *argv[]){
      int tamanhoRam= 1000;
      int tamanhoCache1 = 8;
      int tamanhoCache2 = 16;
      int tamanhoPrograma = 1000;
      int qdePalavrasBloco = 4;
  
      BlocoMemoria *ram = gerarBM(ram, tamanhoRam);
      BlocoMemoria *cache1 = gerarBM(cache1, tamanhoCache1);
      BlocoMemoria *cache2 = gerarBM(cache2, tamanhoCache2);
  
      montarRam(ram, tamanhoRam, qdePalavrasBloco);
      montarCacheVazia(tamanhoCache1, cache1);
      montarCacheVazia(tamanhoCache2, cache2);
  
      Instrucao *memoriaInstrucoes = montarInstrucoesProgramaAleatorio(memoriaInstrucoes, tamanhoPrograma, qdePalavrasBloco, tamanhoRam);
  
      maquina(memoriaInstrucoes, ram, cache1, cache2);
      deleteBM(cache2);
      deleteBM(cache1);
      deleteBM(ram);
      deleteInst(memoriaInstrucoes);
      cout&lt;&lt;"terminou\n";
  
      return 0;
  }
  </code></pre>
  
  <p>This is my blocoMemoria.cpp:</p>
  
  <pre><code>#include "blocoMemoria.hpp"
  using namespace std;
  struct blocoMemoria{
          int *palavras = new int[4];
          int endBloco = -1;
          bool atualizado = false;
          int custo = 0;
          int cacheHit = 0;
  };
  
  BlocoMemoria* gerarBM(BlocoMemoria* b, int q){
      b=new BlocoMemoria[q];
      return b;
  }
  BlocoMemoria *posToPoint(BlocoMemoria *z, int k){
      BlocoMemoria *aux=&amp;z[k];
      return aux;
  }
  
  void deleteBM(BlocoMemoria *a){
      delete a;
  }
  
  void juntarBM(BlocoMemoria *a, BlocoMemoria *b, int i){
      if(i==1){
          setPalavras(a, getPalavras(b));
          setEndBloco(a, getEndBloco(b));
          setAtualizado(a, isAtualizado(b));
          setCusto(a, getCusto(b));
          setCacheHit(a, getCacheHit(b));
      }
  
      else{
          setPalavras(&amp;a[i], getPalavras(b));
          setEndBloco(&amp;a[i], getEndBloco(b));
          setAtualizado(&amp;a[i], isAtualizado(b));
          setCusto(&amp;a[i], getCusto(b));
          setCacheHit(&amp;a[i], getCacheHit(b));
      }
  }
  
  int getCusto(BlocoMemoria *c) {
      return c-&gt;custo;
  }
  
  void setCusto(BlocoMemoria *c, int custo) {
      c-&gt;custo = custo;
  }
  
  int* getPalavras(BlocoMemoria *c) {
          return c-&gt;palavras;
  }
  
  int* getPalavras(BlocoMemoria *c, int i) {
          return c[i].palavras;
  }
  
  void setPalavras(BlocoMemoria* c,int *palavras) {
      c-&gt;palavras = palavras;
  }
  
  int getEndBloco(BlocoMemoria *c) {
      return c-&gt;endBloco;
  }
  
  void setEndBloco(BlocoMemoria *c, int endBloco) {
      c-&gt;endBloco = endBloco;
  }
  
  bool isAtualizado(BlocoMemoria *c) {
      return c-&gt;atualizado;
  }
  
  void setAtualizado(BlocoMemoria *c) {
      c-&gt;atualizado = !c-&gt;atualizado;
  }
  void setAtualizado(BlocoMemoria *c, bool d) {
      c-&gt;atualizado = d;
  }
  
  int getCacheHit(BlocoMemoria *c) {
      return c-&gt;cacheHit;
  }
  
  void setCacheHit(BlocoMemoria *c, int cacheHit) {
      c-&gt;cacheHit = cacheHit;
  }
  </code></pre>
  
  <p>I'm a bit of a noob so i have no idea why this is happening if i'm returning the right pointer at:</p>
  
  <pre><code>BlocoMemoria* gerarBM()
  </code></pre>
  
  <p>I tried just declaring them in the main as
      BlocoMemoria*ram=new BlocoMemoria[];
  but the compiler doesn't like that very much.</p>
  
  <p>the reason i need this fixed is because there arent any operations being made in the main program execution.</p>
  
  <p>it does compile without the -Wall</p>
  
  <p>been doing this for hours and am getting kind of desperate and dont know if im even giving the necessary info, if  you need anything just let me know and ill edit this, thanks.</p>