[Bug 1826820] [NEW] calling setjmp destruct a variable

Launchpad Bug Tracker 1826820 at bugs.launchpad.net
Mon Apr 29 04:16:43 UTC 2019


You have been subscribed to a public bug:

In Ubuntu 18.04 armhf with gcc-7, the following code, which compiles
normally, gives incorrect result (on my machine, -964176505 instead of
correct value 1).

#include <setjmp.h>
#include <stdio.h>

jmp_buf a[10] ;
jmp_buf * volatile sp = a ;

int main()
{
    if (setjmp(*sp++) == 0) {
	printf("diff=%td\n", sp-a) ;
	return 0 ;
    }
    return 1 ;
}

Additional information:
The above code gives correct answer on Ubuntu 16.04 x86_64 gcc 5.4.
If I replace '*sp++' with '*++sp', the program gives correct value 1.

** Affects: gcc-7 (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: armhf gcc setjmp
-- 
calling setjmp destruct a variable
https://bugs.launchpad.net/bugs/1826820
You received this bug notification because you are a member of Ubuntu Foundations Bugs, which is subscribed to gcc-7 in Ubuntu.



More information about the foundations-bugs mailing list