[Bug c++/92951] New: extern variable declaration doesn't behave properly for me
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92951 Bug ID: 92951 Summary: extern variable declaration doesn't behave properly for me Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: fportera2 at gmail dot com Target Milestone: --- I have a global variable 'traindata' declared in cnn.cpp: arma::mat traindata; , I'm importing this varible in mean_squared_error.hpp: #include extern arma::mat traindata; and I'm trying to exploit this variable in mean_squared_error_impl.hpp (that includes 'mean_squared_error.hpp'), for example: printf("n_rows = %d, n_cols = %d\n", traindata.n_rows, traindata.n_cols); but it gives me that the dimensions are 0's (while in the cnn.cpp' main() they are positive). thanks
[Bug c++/92951] extern variable declaration doesn't behave properly for me
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92951 --- Comment #2 from Filippo Portera --- I printf the variable dimensions both in the main() that in: void MeanSquaredError::Backward( int begin, int batch_size, const InputType&& input, const TargetType&& target, OutputType&& output) { double gamma = 1; printf("n_rows = %d, n_cols = %d\n", traindata.n_rows, traindata.n_cols); that I'm sure it is called inside the main function and before the first main's printf. Il giorno lun 16 dic 2019 alle ore 09:39 pinskia at gcc dot gnu.org < gcc-bugzi...@gcc.gnu.org> ha scritto: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92951 > > --- Comment #1 from Andrew Pinski --- > Is the printf before or after main? > > If before, then the problem is the order of variables initialized from > different translational units is unspecified and therefore undefined. > > If after, then maybe something is changing them. > > -- > You are receiving this mail because: > You reported the bug.
[Bug c++/92951] extern variable declaration doesn't behave properly for me
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92951 --- Comment #4 from Filippo Portera --- Created attachment 47503 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47503&action=edit main file where training is defined
[Bug c++/92951] extern variable declaration doesn't behave properly for me
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92951 --- Comment #5 from Filippo Portera --- Created attachment 47504 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47504&action=edit include file where training is declared as extern
[Bug c++/92951] extern variable declaration doesn't behave properly for me
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92951 --- Comment #6 from Filippo Portera --- Created attachment 47505 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47505&action=edit implementation file where I would like to use the training variable
[Bug c++/92951] extern variable declaration doesn't behave properly for me
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92951 Filippo Portera changed: What|Removed |Added Resolution|INVALID |FIXED
[Bug c++/92951] extern variable declaration doesn't behave properly for me
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92951 --- Comment #9 from Filippo Portera --- Fixed! Thanks a lot! Il giorno lun 16 dic 2019 alle ore 12:28 pinskia at gcc dot gnu.org < gcc-bugzi...@gcc.gnu.org> ha scritto: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92951 > > --- Comment #8 from Andrew Pinski --- > NOTE yes there is a missing -Wshadow warning, I will file it in a second. > > -- > You are receiving this mail because: > You reported the bug.
[Bug c++/92951] extern variable declaration doesn't behave properly for me
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92951 Filippo Portera changed: What|Removed |Added Resolution|INVALID |WORKSFORME