1

My problem is in the following code (win8 x64, visual studio):

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>  
#define ARMA_USE_BLAS
#define ARMA_USE_LAPACK
#include <armadillo>

using namespace std;
using namespace arma;

int main() {
    int b_mean = 20;
    int b_max = 4 * b_mean;
    double p = 0.04265748215642;
    double F_bmax = 1 - pow((1 - p), (b_max + 1));
    double alpha = 0.1;

    vector<double> THR(EMAXRANGE + 1, 0);
    vector <vector <int> > q_finali(EMAXRANGE + 1, vector <int>(4, 0));

    const int MAX_E = 8;

    const int ORDINE = (int) pow((MAX_E + 1), 2);

    printf("EMAX=%d \n", MAX_E);
    const int etilde = (int) ceil((double) (MAX_E) / 2);

    //costruisco index
    vector <vector <int> > index(ORDINE, vector <int>(2, 0));
    int riga = 0;
    int i, j;
    for (i = 0; i <= MAX_E; i++) {
        for (j = 0; j <= MAX_E; j++) {
            index[riga][0] = i;
            index[riga][1] = j;
            //printf("i=%d, j=%d, riga=%d \n",i,j,riga);
            riga++;
        }

    }
    // costruisco Q
    vector <vector <int> > Q((2 * MAX_E) + 1, vector <int>(2, 0));
    Q[0][0] = 0; Q[0][1] = 0;
    riga = 1;
    for (j = 1; j <= MAX_E; j++) {
        Q[riga][0] = 0;
        Q[riga][1] = j;
        riga++;
    }
    for (i = 1; i <= MAX_E; i++) {
        Q[riga][0] = i;
        Q[riga][1] = 0;
        riga++;
    }

    int q_LL, q_LH, q_HL, q_HH;
    double G_max = 0;

    vector <vector <double> > P(ORDINE, vector <double>(ORDINE, 0));
    vector <double> g(ORDINE);

    int row;
    int tmp1;
    int tmp2;
    double rew;
    double temp;

#pragma omp parallel for
    for (q_HH = 1; q_HH <= (2 * MAX_E); q_HH++) {
        printf("q_HH=%d \n", q_HH);

        mat A = mat(ORDINE, ORDINE);

        /////// other things //////////
    }
}

All is working correctly, until the matrix definition, when an error occurs. This is my output:

 'Prova.exe' (Win32): caricamento di 'C:\Users\Davide\Documents\Visual Studio 2012\Projects\Prova\Debug\Prova.exe' completato. Simboli caricati.
'Prova.exe' (Win32): caricamento di 'C:\Windows\SysWOW64\ntdll.dll' completato. Impossibile trovare o aprire il file PDB.
'Prova.exe' (Win32): caricamento di 'C:\Program Files\AVAST Software\Avast\snxhk.dll' completato. Impossibile trovare o aprire il file PDB.
'Prova.exe' (Win32): caricamento di 'C:\Windows\SysWOW64\kernel32.dll' completato. Impossibile trovare o aprire il file PDB.
'Prova.exe' (Win32): caricamento di 'C:\Windows\SysWOW64\KernelBase.dll' completato. Impossibile trovare o aprire il file PDB.
'Prova.exe' (Win32): caricamento di 'C:\Windows\SysWOW64\msvcp110d.dll' completato. Simboli caricati.
'Prova.exe' (Win32): caricamento di 'C:\Windows\SysWOW64\msvcr110d.dll' completato. Simboli caricati.
'Prova.exe' (Win32): caricamento di 'C:\Windows\SysWOW64\vcomp110d.dll' completato. Simboli caricati.
'Prova.exe' (Win32): caricamento di 'C:\Windows\SysWOW64\user32.dll' completato. Impossibile trovare o aprire il file PDB.
'Prova.exe' (Win32): caricamento di 'C:\Windows\SysWOW64\gdi32.dll' completato. Impossibile trovare o aprire il file PDB.
'Prova.exe' (Win32): caricamento di 'C:\Windows\SysWOW64\imm32.dll' completato. Impossibile trovare o aprire il file PDB.
'Prova.exe' (Win32): caricamento di 'C:\Windows\SysWOW64\msctf.dll' completato. Impossibile trovare o aprire il file PDB.
'Prova.exe' (Win32): caricamento di 'C:\Windows\SysWOW64\msvcrt.dll' completato. Impossibile trovare o aprire il file PDB.
Debug Assertion Failed!

Program: C:\Windows\SYSTEM32\MSVCP110D.dll
File: c:\program files (x86)\microsoft visual studio 11.0\vc\include\vector
Line: 1140

Expression: vector subscript out of range

For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.

(Press Retry to debug the application)
Second Chance Assertion Failed: File c:\program files (x86)\microsoft visual studio 11.0\vc\include\vector, Line 1140
Prova.exe ha avviato un punto di interruzione.

I think it is something caused by the matrix definition, as if I comment that line all runs smoothly.

Here it is a translation of the error message:

     'Prova.exe' (Win32): loading of 'C:\Users\Davide\Documents\Visual Studio 2012\Projects\Prova\Debug\Prova.exe' completed. Symbols loaded.
'Prova.exe' (Win32): loading of 'C:\Windows\SysWOW64\ntdll.dll' completed. Impossible to find or open the PDB file.
'Prova.exe' (Win32): loading of 'C:\Program Files\AVAST Software\Avast\snxhk.dll' completed. Impossible to find or open the PDB file.
'Prova.exe' (Win32): loading of 'C:\Windows\SysWOW64\kernel32.dll' completed. Impossible to find or open the PDB file.
'Prova.exe' (Win32): loading of 'C:\Windows\SysWOW64\KernelBase.dll' completed. Impossible to find or open the PDB file.
'Prova.exe' (Win32): loading of 'C:\Windows\SysWOW64\msvcp110d.dll' completed. Symbols loaded.
'Prova.exe' (Win32): loading of 'C:\Windows\SysWOW64\msvcr110d.dll' completed. Symbols loaded.
'Prova.exe' (Win32): loading of 'C:\Windows\SysWOW64\vcomp110d.dll' completato. Symbols loaeded.
'Prova.exe' (Win32): loading of 'C:\Windows\SysWOW64\user32.dll' completed. Impossible to find or open the PDB file.
'Prova.exe' (Win32): loading of 'C:\Windows\SysWOW64\gdi32.dll' completed. Impossible to find or open the PDB file.
'Prova.exe' (Win32): loading of 'C:\Windows\SysWOW64\imm32.dll' completed. Impossible to find or open the PDB file.
'Prova.exe' (Win32): loading of 'C:\Windows\SysWOW64\msctf.dll' completed. Impossible to find or open the PDB file.
'Prova.exe' (Win32): loading of 'C:\Windows\SysWOW64\msvcrt.dll' completed. Impossible to find or open the PDB file.
Debug Assertion Failed!

Program: C:\Windows\SYSTEM32\MSVCP110D.dll
File: c:\program files (x86)\microsoft visual studio 11.0\vc\include\vector
Line: 1140

Expression: vector subscript out of range

For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.

(Press Retry to debug the application)
Second Chance Assertion Failed: File c:\program files (x86)\microsoft visual studio 11.0\vc\include\vector, Line 1140
Prova.exe has run an interruption point.
5
  • It might be helpful to translate the error messages into English for those of us who don't read Italian or whatever it is...
    – twalberg
    Sep 30, 2013 at 16:50
  • Done! Thank you if you'll try to help me Oct 1, 2013 at 13:33
  • Did you read the error message? Expression: vector subscript out of range. Fix that.
    – stefan
    Oct 1, 2013 at 13:35
  • What is EMAXRANGE defined as? The other constants you use for sizing your vectors seem well defined (if a bit oddly...) - MAX_E == 8, ORDINE == 64. You do realize array indexing of array[N] goes from 0 to N-1, right? I see a bunch of <= in loop termination conditions, which is suspect, but you also size your arrays as N+1 for the most part, so maybe that's ok; but if you missed one somewhere, that could easily be the problem...
    – twalberg
    Oct 1, 2013 at 13:47
  • EMAXRANGE is defined as: #define EMAXRANGE 20 The fact is i don't understand why error "Expression: vector subscript out of range" is thrown as it comes only with the initialization of the matrix, and only if the pragma omp.. command is used. if i run this program without the pragma command no error is thrown Oct 2, 2013 at 6:28

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.