Why does DSPIC33F restarts when timer interrupt flag is addressed?
Page 2 in the PIC33f Interrupts family reference illustrates how interrupt process works for the dsPIC33f:

http://ww1.microchip.com/downloads/en/DeviceDoc/70300C.pdf

When you enable an interrupt (e.g. T2IE) and the interrupt fires it goes to the address location found at the peripheral interrupt vector. if you did not define a legal address for the peripheral the peripheral interrupt vector will have an unknown address (perhaps 0) and when the interrupt will fire it will go to that address and unpredictable things can happen

in your case, assuming the ALTIVT bit (INTCON2&lt;15>) is cleared, when the the TMR2 interrupt fires it will go to the address location found in 0x000022.

when you write:

void __attribute__((__interrupt__, auto_psv)) _T2Interrupt (void)
{

}


you actually telling your compiler that you would like to place the address of the start of this code at address 0x000022 (TMR2 IVT Address)

and when you write:

void __attribute__((__interrupt__, auto_psv)) _AltT2Interrupt (void)
{

}


you are telling your compiler to place the address of the start of this code at address 0x000122 (TMR2 AIVT Address)